+ 1
Currency Converter
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
82 Réponses
+ 46
Hey there!
Priya Ghosh
This is the solution for the python code:
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount,rate){
return amount * rate
}
+ 22
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert(amount, rate) {
return amount*rate;
}
console.log(convert(amount, rate));
}
+ 7
function main() {
var amount = parseFloat(readline(),10);
var rate = parseFloat(readLine(),10);
console.log(convert(amount, rate));
function convert (amount, rate){
var result = amount * rate;
return result;
}
}
+ 4
//Here is my Solution
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert (a,b){
return amount*rate;
}
convert();
console.log(convert(amount, rate));
}
If I'm right its simply Multiply the given amount with the set rate and returns the product.
+ 3
@Caleb can you help me ?
Arrays
The array you are given represents the menu of breakfast options available at the hotel.
The Chef decided to replace one of the options with "Fluffy Pancakes".
Write a program to take the index as input, replace the element with that index with "Fluffy Pancakes", and output the new menu to the console as an array.
Sample Input
2
Sample Output
[
'Cinnamon Doughnuts',
'Waffles',
'Fluffy Pancakes',
'Chorizo Burrito',
'French Toast'
]
The element with index 2 has been replaced in the output array. this question.
and my code is -
function main() {
var breakfasts = ['Cinnamon Doughnuts', 'Waffles', 'Fluffy Pancakes', 'Chorizo Burrito', 'French Toast'];
var index = parseInt(readLine(), 10)
//replace the corresponding element by "Fluffy Pancakes"
//output the menu to the console
document.write(breakfasts[2]);
}
but getting error.
+ 2
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));
}
+ 2
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
function convert(amount, rate){
return amount*rate
}
convert()
}
+ 2
Hey guys , this is the simplest approach to the solution
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount,rate){
return amount * rate
}
+ 2
you can try this
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
function convert(amount,rate){
return amount*rate;
}
console.log(convert(amount, rate));
}
+ 1
No I couldn't solve this . Can you solve this ? It will help me a lot.
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
you start with this and if you change the:
console.log(convert(amount, rate));
to make it rate times amount it works
+ 1
No I can't understand. can you showcase me the complete code?
+ 1
Caleb
It's not solving.
+ 1
Priya Ghosh
wow!! you took me way too literally. i was trying to lead you to this:
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(rate * amount);
}
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(amount * rate);
}
+ 1
add this
function convert(amount,rate){
return amount * rate
}
+ 1
function main() {
var amount = parseFloat(readLine(), 10);
var rate = parseFloat(readLine(), 10);
console.log(convert(amount, rate));
}
function convert(amount,rate){
c = amount*rate
return c
}
0
you're attempt?
0
Caleb lemme try once will let you know.
0
Showing error. caleb can we connect on any social media ??? Please .