help me about this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

help me about this code

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: 110Converting 100 at the rate of 1.1 is equal to 100*1.1 = 110. function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); }

8th Nov 2021, 4:35 AM
Turg'unboyev Davlat
Turg'unboyev Davlat - avatar
2 Answers
+ 2
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } Then create a function called convert that takes two parameters that are amount and rate. function convert(amount,rate){ let cvt = amount * rate; //At last return amount * rate return cvt; } this may help
8th Nov 2021, 4:58 AM
Mohamed Aazir Abdul Hathi
Mohamed Aazir Abdul Hathi - avatar
+ 1
Turg'unboyev Davlat Review lesson 26.1 of your Javascript tutorial. The answer is there!
8th Nov 2021, 8:02 AM
Rik Wittkopp
Rik Wittkopp - avatar