+ 1

Hi guys who can solve the take a trip code test in Javascript lesson here

11th Jun 2022, 1:15 PM
Funsho Ajayi
Funsho Ajayi - avatar
23 Respostas
+ 3
Funsho Ajayi yeah see my code👇👇👇👇👇 function main() { var distance = parseInt(readLine(), 10); //your code goes here console.log((distance/40)*60); }
11th Jun 2022, 3:35 PM
NonStop CODING
NonStop CODING - avatar
+ 4
The variable "distance" is input by a user/the system. I think I've seen A͢J mention before.. Think of adding 2 numbers and outputting the result. You can of course write a program that does: 2 + 3 = 5 But what if the user wants to tell your program different numbers? So, you create variables a, b and c. a + b = c a and b are inputs and no matter what the user wants, your programs will work. If the user wants 3 inputs though... that is for another day.
13th Jun 2022, 8:20 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
I think many have and can. Do you want help with your attempt? Can you copy your code into the code playground and attach it here?
11th Jun 2022, 1:47 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
There's a distinct difference between your code and NonStop CODING . Your code is trying to solve one case only because you have input the exact amount of miles from case 1. Nonstop's code accepts the input "distance" and can solve all cases/possibilities. Try it. If it works, please remember: you are coding to solve many different needs and problems, not just a single case or possibility.
11th Jun 2022, 7:42 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Funsho Ajayi my code is 100% correct just run it in the trip planner project😎 i used the most basic formula distance = speed * time so time = distance / speed then convert this time into minutes by multiplying with60 so final answer 👇👇👇 (distance / speed) * 60 // given speed = 40 mph
14th Jun 2022, 1:17 AM
NonStop CODING
NonStop CODING - avatar
+ 2
Funsho Ajayi post this new question in a new post not here and edit the current post and write [ SOLVED ] in front of it (if it has solved). like this 👇👇👇👇 [ SOLVED ] Hi guys who can solve the take...................here
15th Jun 2022, 11:34 PM
NonStop CODING
NonStop CODING - avatar
+ 1
Funsho Ajayi Share your solution
11th Jun 2022, 2:12 PM
A͢J
A͢J - avatar
+ 1
Funsho Ajayi we are not same bro. Copy paste my code you'll see how it works🙃🙂🙃🙂🙃🙂. read Ausgrindtube comment😍
12th Jun 2022, 2:27 AM
NonStop CODING
NonStop CODING - avatar
+ 1
It's because "distance" in this program is the input variable name. Change var distance And console.log((distance/40) To any word you want. var littlePig console.log((littlePig/40)
15th Jun 2022, 5:42 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
And tag the programming language and attach your attempt from the code playground.
16th Jun 2022, 5:29 AM
Ausgrindtube
Ausgrindtube - avatar
0
Its the question I don't understand
11th Jun 2022, 1:59 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
I solved the code for the first output but the second one needs to be outputted as well
11th Jun 2022, 2:00 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
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
11th Jun 2022, 3:26 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
function main() { var distance = parseInt(readLine(), 10); //your code goes here var mPH = 40; var m = 590; mPH = m/mPH; var mPM = 60; mPM *= mPH; console.log(mPM); }
11th Jun 2022, 3:26 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
Here's my code above
11th Jun 2022, 3:26 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
Thanks but.... It's the same as my code... I need some one show me his to pass that test in the JavaScript class... How do I input the answer for the different tests at the same time without them clashing
11th Jun 2022, 4:52 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
Wow
13th Jun 2022, 7:14 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
So how was the input distance correct
13th Jun 2022, 7:14 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
I don't get how this nonstop Coding code is correct.. Can you explain pls thank you
13th Jun 2022, 7:15 PM
Funsho Ajayi
Funsho Ajayi - avatar
0
If I don't use the word do "Distance" the code won't work So this particular word coz I tried it before without that word
15th Jun 2022, 5:21 PM
Funsho Ajayi
Funsho Ajayi - avatar