+ 5

I need help with JavaScript currency converter problem

I don’t know what to do to complete this problem function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } Can anyone help me plz

24th Dec 2020, 3:42 AM
Saif Aljubori
Saif Aljubori - avatar
10 Réponses
+ 14
Here is my solution: function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert (a,b){ var c = a * b; return c } console.log(convert(amount, rate)); }
4th Feb 2021, 8:39 PM
Who Cares
+ 2
convert (42,0.72) function convert(amount,rate){ console.log (amount*rate); } I don’t know how to add diffren amount and rate to fix this problem?
8th Jan 2021, 5:06 PM
Saif Aljubori
Saif Aljubori - avatar
+ 2
Hi all ! I have difficulties to achieve this practise. This is my code and I can't see what is wrong. I have the error "NaN" in every test cases... function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(montant, taux) { var nvxMontant = montant * taux; return nvxMontant; } console.log(convert(amount, rate)); } main(); Could someone help me please ?
8th Aug 2021, 2:41 PM
Kaemyll Selendaer
Kaemyll Selendaer - avatar
+ 1
Saif Aljubori function convert(amount,rate){ var total = amount* rate ; return total; }
1st Jan 2021, 9:27 PM
Hayder Hussien
Hayder Hussien - avatar
+ 1
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(){ amount => amount; rate => rate; return amount*rate; } convert(); }
9th Jul 2021, 10:27 PM
Mauled Hamad
Mauled Hamad - avatar
+ 1
Roman Vasylyna Don't call main function Code is running on Node server so no need to call main function
12th Oct 2021, 7:30 PM
A͢J
A͢J - avatar
0
Saif Aljubori Where is your attempts? To solve the problem go through the lessons again.
24th Dec 2020, 3:43 AM
A͢J
A͢J - avatar
0
Function convert(a,b){ Var c=a*b; Return c; } Console.log(convert(amount,rate));
10th Jun 2021, 1:56 PM
Mahsa Baniasad Askari
0
For some reason I am having NaN error even though the solution is correct function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); } function convert(a, b) { return a*b; } main();
12th Oct 2021, 6:54 PM
Roman Vasylyna
Roman Vasylyna - avatar
0
Give that function main () { Var amount = parseFloat(readLine(), 10); Var rate = parseFloat(readLine(), 10); Use to function Function convert (amount, rate){ return amount*rate; } Console.log(convert (amount,rate)); }
22nd Sep 2022, 6:45 AM
Dasanjaneyulu
Dasanjaneyulu - avatar