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
node solution.js