0
How to solve this using Java script function?
You need to plan a road trip. You are traveling at an average speed of 40 miles an hour. Given a distance in miles as input (the code to take input is already present), output to the console the time it will take you to cover it in minutes.
3 Answers
0
Thank you so much.
Could you explain the first statement of this js
Hi,
an easy way to solve it is the following one:
var distance = parseInt(readLine(), 10);
+ 1
Hi,
an easy way to solve it is the following one:
var distance = parseInt(readLine(), 10);
var speed = 40;
var result = (distance/speed)*60;
console.log(result);
Cheers
0
Sure.
readLine() method to read the input.
parseInt(string, base) : change the data type of the input (string) to Int having base 10.
Then we assign it to a variable called distance to use it.
Cheers