+ 1
Someone solve me this question. It's in JavaScript. Also explain of possible.
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. Sample Input: 150 Sample Output: 225
11 Answers
+ 8
Ahnaf Abid use this
function main() {
var distance = parseInt(readLine(), 10);
var result =distance/40 *60 ;
console.log(result);
}
+ 7
Can you post your attempts or code where you're getting error ??
Actually you have to take an integer input and divide it by 40 (to calculate the hours covering the distance entered)
After that multiply it to 60 (for converting hours into minutes)
Then Display it
Hope this hint helps!
+ 6
Ahnaf Abid you have missed var and also while displaying the output
Display the variable result
As it contains the required output not the distance because it's an input
+ 5
Ahnaf Abid good it's solve 👍🏻👌🏻
Happy to help 😊
+ 4
Ahnaf Abid Ok then use this 👇🏻
As you have said that the code to take input is mentioned so you have to declare a variable and calculate the result by dividing the distance by 40 then multiplying by 60
var result = distance / 40 * 60;
console.log(result);
+ 2
I'm learning JavaScript new. I solved first few codes while learning. But this one I'm having difficulty to put the input. I completed till lesson 12. 13 no lesson is this code that I am trying to solve.
+ 1
Ok thank you. I understand now.
+ 1
Suparna thank you it's now, solved
0
function main() {
var distance = parseInt(readLine(), 10);
va =distance/40 *60 ;
console.log(distance);
}
0
I put this still output not coming that was expected to come.
0
Oh I missed the var