Currency Converter In JavaScript | Sololearn: Learn to code for FREE!

+3

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

1/6/2021 6:19:55 PM

Henrique Hoffmann

+12

function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(a,b){ return a*b; } }

+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)); }

+1

function main() { var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); console.log(convert(amount, rate)); function convert(x,y){ return x*y; } }

+1

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 .

0

Show us your attempt

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

0

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

0

var amount = parseFloat(readLine(), 10); var rate = parseFloat(readLine(), 10); function convert(a, r) { return a * r; } console.log(convert(amount, rate)); }

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; } }

0

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)); }

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; }

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

0

can somebody tell me the purpose of the main function please!

-1

thanks