+ 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
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;
}
}
+ 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));
}
+ 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));
}
+ 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
+ 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
+ 1
What does parseFloat(readLine() mean and where does it come from? Thanks.
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));
function convert(x,y){
return x*y;
}
}
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);
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!
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 .
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));
}
0
function main() {
var amount = parseFloat(readLine(),10);
var rate = parseFloat (readLine(),10);
function convert(amount,rate) {
return amount*rate;
}
}
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));
}
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
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 ;
}