- 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
9 Antworten
+ 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
+ 3
You write your code for single input instead of general use for different test cases
console.log(convert(amount,rate));
+ 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.
+ 1
nothing...
what would you expect?
+ 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 :(
+ 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.
0
it keeps saying wrong
0
explain to me further please
- 1
it worked