0

Function Parameters Bug (Please help)

https://code.sololearn.com/cTlMELyDalnS/?ref=app You are given a program that takes salary as input. Complete the function in order to calculate and output the savings. Sample Input 200 Sample Output 30

20th Dec 2021, 10:50 PM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
2 odpowiedzi
+ 1
Here is the code, I completed the functions but there still a bug : readLine is not defined, readLine is a custom function made by SoloLearn for its JS Challenges, you may use prompt() when using JS with HTML, but if you want to take user input from node, you have to define your own readLine() : const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout }); readLine(main); function readLine(func, str="") { readline.question(str , res => { func(res); readline.close(); }); } function main(s) { const salaryAmount = parseInt(s, 10), savings = getSavings(salaryAmount); console.log(getSavings(salaryAmount)); } function getSavings(salary) { return salary * .15 }
25th Dec 2021, 1:35 AM
VCoder
VCoder - avatar
+ 1
VCoder Thank you for this. I will try it. Edit: I tried it and received NaN in the console. Could you tell me what is the significance of the s and 10 in the code? Is ‘s’ just a variable for salary? I’m confused about the presence of the ‘10’ inside the code. Thanks for your help with this.
25th Dec 2021, 3:11 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar