Hacker rank Bill

Run Settings
LanguageJavaScript
Language Version
Run Command
//also use arr.reverse function processData(input) { let string = input.split('\n'); let k = string[0].split(" ")[1]; let bill = string[1].split(" ").map(Number); let b = string[2] let res = 0 const total = bill.reduce((a, b)=>{ return a+b; }); const discount = bill[k]; const refund = b - (total - discount) / 2; if (refund != 0){ console.log(refund); }else{ console.log("Bon Appetit"); } } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
Editor Settings
Theme
Key bindings
Full width
Lines