+ 4

Currency Converter In JavaScript

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 I'm trying but its wrong

6th Jan 2021, 6:19 PM
Henrique Hoffmann
Henrique Hoffmann - avatar
25 Answers
+ 22
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(a,b){ return a*b; } }
28th Jan 2021, 10:24 AM
Derrick Titus
Derrick Titus - avatar
+ 4
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); //add a function then return it: how to use function properly function convert (amount, rate) { return (amount * rate); } console.log(convert(amount, rate)); }
12th Mar 2021, 9:23 AM
Ali Ameen
+ 3
// Please read carefuly the task. That is all what will be needed to code: function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(a,r){ return a*r; } console.log(convert(amount, rate)); }
6th Jan 2021, 7:00 PM
JaScript
JaScript - avatar
+ 3
function convert() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); amount = amount*rate; console.log(amount); } convert (); //Simple in jus one function
26th Jun 2022, 11:02 AM
Navya Bade
+ 1
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); var amount = parseFloat(document.getElementById("amount").value); var result = document.getElementById("result"); if (select.value === "amount") { result.value = (amount * 1.1); } I tryed it
6th Jan 2021, 6:40 PM
Henrique Hoffmann
Henrique Hoffmann - avatar
+ 1
What does parseFloat(readLine() mean and where does it come from? Thanks.
12th Dec 2022, 2:46 PM
Lusine Galstyan Nikolay
Lusine Galstyan Nikolay - avatar
0
Show us your attempt
6th Jan 2021, 6:22 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
0
Can you link the code so we can see where you are going wrong ? Or copy paste the code if you can't link it
6th Jan 2021, 6:23 PM
Abhay
Abhay - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(x,y){ return x*y; } }
27th Jan 2021, 10:07 AM
Arcrun Barikyan
Arcrun Barikyan - avatar
0
var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(a, r) { return a * r; } console.log(convert(amount, rate)); }
29th Jan 2021, 9:51 PM
Younes Elmansouri Elmoudan
Younes Elmansouri Elmoudan - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(a,b){ return a*b; } }
8th Feb 2021, 10:19 AM
Md Momin Uddin Hridoy
Md Momin Uddin Hridoy - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } function convert(a, b){ return a * b; }
5th Jul 2021, 6:09 PM
Matt Limoges
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } function convert(amount, rate) { return amount * rate; } var x = convert(100, 1.1); its working
17th Aug 2021, 12:13 PM
Swadhin Kumar
Swadhin Kumar - avatar
0
can somebody tell me the purpose of the main function please!
25th Aug 2021, 2:49 PM
Arwa Hassan
Arwa Hassan - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(amount , rate){ var p = amount*rate; return p; } console.log(convert(amount, rate)); } This the answer .
27th Aug 2021, 11:47 AM
Ehsan Safari
Ehsan Safari - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(amount,rate){ return amount*rate; } console.log(convert(amount, rate)); }
18th Dec 2021, 7:42 PM
Mahmood Qanbari
Mahmood Qanbari - avatar
0
function main() { var amount = parseFloat(readLine(),10); var rate = parseFloat (readLine(),10); function convert(amount,rate) { return amount*rate; } }
20th Feb 2022, 9:58 AM
Sokol Hajri
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); //code or put your function here function convert (amount, rate) { return (amount * rate); } console.log(convert(amount, rate)); }
26th Feb 2022, 9:13 AM
Nana Nyarko
Nana Nyarko - avatar
0
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
3rd Jun 2022, 2:38 PM
Aida Rose palmaira
Aida Rose palmaira - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } function convert(amount,rate){ return amount*rate ; }
18th Jul 2022, 3:36 PM
Abdulhamit TURAN
Abdulhamit TURAN - avatar