We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm using JavaScript and knows how to solve this problem, but I'm not familiar with these i/o methods that's being used. Can someone here guide me on the problem with my code? I'm still trying to get used to how this site works.
function processData(input, tips, taxes) {
//Enter your code here
var mealCost = input,
tipPercent = tips,
taxPercent = taxes,
tip = mealCost * (tipPercent / 100),
tax = mealCost * (taxPercent / 100),
totalCost = Math.round(mealCost + tip + tax);
return totalCost;
}
process.stdout.write('The total meal cost is ' + processData(12, 20, 8) + ' dollars.');
process.stdout.write('The total meal cost is ' + processData(15.50, 15, 10) + ' dollars.');
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
Hi,
I'm using JavaScript and knows how to solve this problem, but I'm not familiar with these i/o methods that's being used. Can someone here guide me on the problem with my code? I'm still trying to get used to how this site works.