- 1

What’s wrong with my code

function convert(amount, rate) { return amount * rate; } var x = convert(42, 0.72); console.log(x); You are making a currency converter app. Create a function called convert, which takes two parameters: the amount to convert, and the rate, and returns the resulting amount. The code to take the parameters as input and call the function is already present in the Playground. Create the function to make the code work. Sample Input: 100 1.1 Sample Output: 110

28th Jan 2021, 9:00 PM
Kherleel😎🖥
Kherleel😎🖥 - avatar
9 odpowiedzi
+ 2
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert() { return amount*rate; } console.log(convert(amount, rate)); } this will surely do it
30th Jan 2021, 3:19 PM
Yusuf M Hashmi
+ 3
You write your code for single input instead of general use for different test cases console.log(convert(amount,rate));
28th Jan 2021, 9:12 PM
HBhZ_C
HBhZ_C - avatar
+ 3
Did you delete the given code? function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } Just add your convert function to this and it should work.
28th Jan 2021, 9:30 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
nothing... what would you expect?
28th Jan 2021, 9:08 PM
visph
visph - avatar
+ 1
it looks like a code coach... is it one? if so, I guess you're not handling input/output the right way ^^ however, I've never done any code coach, so I cannot help further :(
28th Jan 2021, 9:12 PM
visph
visph - avatar
+ 1
The code above should have been provided for you when you first started the challenge. It handles how the app interacts with your code. SL calls the main() function which is already set up to receive the inputs and print the output that SL is expecting. All you had to do was add your convert function (which is called in main) so that it returns the correct value that is expected for output. Just put that code back, add your convert function (nothing else) and run it.
28th Jan 2021, 10:06 PM
ChaoticDawg
ChaoticDawg - avatar
0
it keeps saying wrong
28th Jan 2021, 9:09 PM
Kherleel😎🖥
Kherleel😎🖥 - avatar
0
explain to me further please
28th Jan 2021, 9:56 PM
Kherleel😎🖥
Kherleel😎🖥 - avatar
- 1
it worked
31st Jan 2021, 11:48 AM
Kherleel😎🖥
Kherleel😎🖥 - avatar