+ 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

27th Aug 2022, 5:01 AM
Ahnaf Abid
Ahnaf Abid - avatar
11 Respuestas
+ 8
Ahnaf Abid use this function main() { var distance = parseInt(readLine(), 10); var result =distance/40 *60 ; console.log(result); }
27th Aug 2022, 5:43 AM
Suparna Das
Suparna Das - avatar
+ 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!
27th Aug 2022, 5:18 AM
Suparna Das
Suparna Das - avatar
+ 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
27th Aug 2022, 5:45 AM
Suparna Das
Suparna Das - avatar
+ 5
Ahnaf Abid good it's solve 👍🏻👌🏻 Happy to help 😊
27th Aug 2022, 5:47 AM
Suparna Das
Suparna Das - avatar
+ 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);
27th Aug 2022, 5:35 AM
Suparna Das
Suparna Das - avatar
+ 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.
27th Aug 2022, 5:34 AM
Ahnaf Abid
Ahnaf Abid - avatar
+ 1
Ok thank you. I understand now.
27th Aug 2022, 5:39 AM
Ahnaf Abid
Ahnaf Abid - avatar
+ 1
Suparna thank you it's now, solved
27th Aug 2022, 5:46 AM
Ahnaf Abid
Ahnaf Abid - avatar
0
function main() { var distance = parseInt(readLine(), 10); va =distance/40 *60 ; console.log(distance); }
27th Aug 2022, 5:42 AM
Ahnaf Abid
Ahnaf Abid - avatar
0
I put this still output not coming that was expected to come.
27th Aug 2022, 5:42 AM
Ahnaf Abid
Ahnaf Abid - avatar
0
Oh I missed the var
27th Aug 2022, 5:44 AM
Ahnaf Abid
Ahnaf Abid - avatar