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.

28th Sep 2021, 11:56 AM
Imran Khan
Imran Khan - avatar
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);
28th Sep 2021, 3:28 PM
Imran Khan
Imran Khan - avatar
+ 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
28th Sep 2021, 1:42 PM
Giancarlo Emanuel Buonomo Giacoponello
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
28th Sep 2021, 4:11 PM
Giancarlo Emanuel Buonomo Giacoponello