+ 2

currency converter

This is not functioning, I think I'm codding like noob. as I am. HaHa! function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); this.amount = amount this.rate = rate var convert= amount*rate console.log(convert(amount, rate)); }

20th Jan 2021, 9:47 PM
Himanshu Thakur
Himanshu Thakur - avatar
4 Antworten
+ 1
function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(amount * rate); }
4th Sep 2021, 1:01 PM
PRO programmer
PRO programmer - avatar
0
this.amount and this. rate won't work as I think you need a constructor function for that which obviously you don't here so remove those lines along with var convert=amount*rate Declare a seperate function outside main function function create(amount,rate) { return amount*rate; }
20th Jan 2021, 10:07 PM
Abhay
Abhay - avatar
0
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:42 PM
Who Cares
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