HELP WRITE CURRENCY CONVERTER | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

HELP WRITE CURRENCY CONVERTER

HELP 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 function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); var convert = rate * amount; console.log(convert(amount, rate)); }

1st Mar 2021, 2:13 AM
Кандыбаев Алишер
Кандыбаев Алишер - avatar
4 Answers
0
function convert(amount, rate) { return amount * rate; }
1st Mar 2021, 2:35 AM
Tomás CL 🇨🇺 (temporarily inactive)
Tomás CL 🇨🇺 (temporarily inactive) - avatar
+ 2
https://www.sololearn.com/Discuss/2710591/?ref=app you must define a function 'convert', not a variable... or at least just output 'convert' variable value ;)
1st Mar 2021, 2:31 AM
visph
visph - avatar
+ 2
Tomás Corrales Lemoine what are you trying to do? you just got a best answer mark for the same question/OP, while you just spoil the problem, as he should implement at least the basics to start learning ^^
1st Mar 2021, 2:43 AM
visph
visph - avatar
+ 1
function convert(amount){ return amount * rate; }
20th Jul 2021, 10:13 AM
Adedeji Moyinoluwa
Adedeji Moyinoluwa - avatar