+ 3
Javascript module projects
I don't understand where do you write the code. Do you have to make a new function or you put it in the existing function
15 Answers
+ 5
Write inside the existing function .
There's a comment like //your code goes here ...Just fill the codes there ...
+ 4
Brenda Michelle
You need to write everything inside the main function because sl calls the main function to start
+ 3
Which project are you talking about? Can you copy its link here or atleast its name here?
+ 3
Brenda Michelle you have written the code in the coorect place. The problem is that you don't have to return anything from the function. Instead, you need to display the answer to the screen. Use the console.log function to display your answer to the screen,
+ 2
Brenda Michelle you can either make a separate variable and log that. For example
var time = your_way_to_calculate_time
console.log(time)
or you can directly log the time without making a separate variable. Example
console.log(your_way_to_calculate_time)
+ 1
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
distance /40 *60;
console.log(distance)
}
0
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
return distance /40 *60;
}
0
XXX thank you! It finally worked. 😊👍
- 1
The trip planner project
- 1
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
- 1
Do i need to log the distance? Or i need to create another variable for thw time?
- 1
- 1
150/40=3.75*60=225
- 1
I keep getting the same number for input and output. Need help in identifying what im doing wrong?
- 1
Brenda Michelle you could either did what you did, using a single variable or this:-
var time = distance /40;
timeinminutes = time * 60;
console.log(timeinminutes);
Either way its still provides the same output. BTW, "console.log" outputs the value of the variable onto the console screen.
UPDATE:- Oh nvm. XXX alright explained.