+ 5

Currency converter

Create a function called convert with two parameters the amount to convert and rate and return the resulting amount.The code to take the parameters as input and call the function which is already in the playground and create a function to make the code work. input =100 1.1 Output =110 Here’s my code /* *convert * *Takes amount rate then returns the resulting amount * *@param double amount * *@param double rate * *@return double amount */ function convert(amount,rate) { return(amount*rate); }

18th Dec 2020, 9:59 AM
Emmanuel Osemudiamen
Emmanuel Osemudiamen - avatar
25 odpowiedzi
+ 15
First start by creating main function that can take input from user i.e currency and rate. 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; } Hope it helps. Cheers!
19th Dec 2020, 5:00 AM
Ddhruv
Ddhruv - avatar
+ 6
function convert(amount, rate){ return amount * rate }
13th Nov 2021, 3:31 PM
Mohammad Amaierh
+ 3
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); const convert= (amount, rate)=> amount * rate; console.log(convert(amount, rate)); }
12th Mar 2021, 11:39 AM
Nick Triandafillidis
Nick Triandafillidis - avatar
+ 3
// Passes all tests function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(amout,rate){ var final=amout*rate; return final; } console.log(convert(amount, rate)); }
23rd Aug 2021, 7:18 AM
Aman Mulani
Aman Mulani - avatar
+ 1
Hi Ddhruv i did like this can you please tell me where i did wrong. function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert (convert ) console.log(convert(amount, rate)); } function convert (100,1.1) let convert(amount*rate) return convert . }
31st Dec 2020, 12:31 PM
Zahor Mohammed Aziz
+ 1
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
+ 1
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. Solution: //leave them as they are. function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } //Date from the question: //function called convert = done //two parameters (amount, rate) = done //return resulting amount = done //input amount = prompt = done //no need function convert(amount, rate) { //prompt = ("insert amount"); //no need //rate = (amount * 1.1); //no need return amount * rate; }; convert(100,1.1); //function is called with the input data from the user. If you like the solution, give it a thumb up. Thanks
21st Aug 2021, 10:46 PM
Medo Hamdani
Medo Hamdani - avatar
+ 1
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); const convert= (amount, rate)=> amount * rate; console.log(convert(amount, rate)); }
11th Oct 2022, 1:11 PM
Ahmed Mu'azu Sabo
Ahmed Mu'azu Sabo - avatar
0
.
28th Dec 2020, 3:47 PM
Zahor Mohammed Aziz
0
this is my poor code 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);
2nd Jan 2021, 8:24 AM
Dani Prasetyo
Dani Prasetyo - avatar
0
Zahor Mohammed Aziz you code is not correct. Curly braces are not correct, function is not properly written. You can see the solution given by Dani Prasetyo it's nearly the same, that you are trying to do. Hope it helps.
2nd Jan 2021, 9:44 AM
Ddhruv
Ddhruv - avatar
0
Thanks for the reply Ddhruv i already solved it.
2nd Jan 2021, 11:14 AM
Zahor Mohammed Aziz
0
Zahor Mohammed Aziz that's great 🤩
2nd Jan 2021, 3:55 PM
Ddhruv
Ddhruv - 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:46 AM
Ehsan Safari
Ehsan Safari - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(amount * rate); }
4th Sep 2021, 1:00 PM
PRO programmer
PRO programmer - avatar
0
function convert(amt,rate){ Var result = amt*rate; return result; } console.log(convert(100,1.1);
7th Dec 2021, 2:18 PM
Munchkin Ibrahim
Munchkin Ibrahim - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); const convert= (amount, rate)=> amount * rate; console.log(convert(amount, rate)); }
12th Dec 2021, 3:22 AM
MN FATHIMA RIHAM - s92064451 -321424451
MN FATHIMA RIHAM - s92064451 -321424451 - avatar
0
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } function convert(amount,rate){ let cvt = amount * rate; //At last return amount * rate return cvt; } Good Luck
13th Dec 2021, 2:11 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
function convert(amount,rate) { return(amount*rate); }
15th Feb 2022, 10:29 AM
Ali Haneef
Ali Haneef - 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)); }
3rd Apr 2022, 7:18 AM
Rajkumar Shil
Rajkumar Shil - avatar