+ 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)); }
4 Réponses
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(amount * rate);
}
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;
}
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));
}
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 .