+ 1
Hi guys who can solve the take a trip code test in Javascript lesson here
24 Answers
+ 3
Funsho Ajayi
yeah see my code๐๐๐๐๐
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
console.log((distance/40)*60);
}
+ 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.
+ 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?
+ 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.
+ 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
+ 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
+ 1
Funsho Ajayi
Share your solution
+ 1
Funsho Ajayi we are not same bro. Copy paste my code you'll see how it works๐๐๐๐๐๐.
read Ausgrindtube comment๐
+ 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)
+ 1
And tag the programming language and attach your attempt from the code playground.
0
Its the question I don't understand
0
I solved the code for the first output but the second one needs to be outputted as well
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
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);
}
0
Here's my code above
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
0
Wow
0
So how was the input distance correct
0
I don't get how this nonstop Coding code is correct.. Can you explain pls thank you
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