Skip to content

Latest commit

 

History

History

getting-the-distinct-transactions

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Getting the distinct transactions

Fix the below code for only the distinct transactions

const solution = (transactions, taxRate) => {
  let numCalls = 0;

  const calculateCostAfterTax = (cost, taxRate) => {
    numCalls = numCalls + 1;
    return cost * taxRate;
  };

  const computeTotal = (taxRate) => {
    return (cost) => {
      return calculateCostAfterTax(cost, taxRate);
    };
  };

  transactions.map(computeTotal(taxRate));

  return numCalls;
};

e.g.:

Input

transactions = [3, 4, 3, 7, 4, 9]
taxRate = 2.5

Output

4

Execute

node solution.js