Javascript module projects | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

14th Jan 2021, 4:58 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
15 Answers
+ 5
Write inside the existing function . There's a comment like //your code goes here ...Just fill the codes there ...
14th Jan 2021, 5:02 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 4
Brenda Michelle You need to write everything inside the main function because sl calls the main function to start
15th Jan 2021, 5:27 AM
Krish
Krish - avatar
+ 3
Which project are you talking about? Can you copy its link here or atleast its name here?
14th Jan 2021, 5:01 PM
XXX
XXX - avatar
+ 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,
14th Jan 2021, 5:12 PM
XXX
XXX - avatar
+ 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)
14th Jan 2021, 5:22 PM
XXX
XXX - avatar
+ 1
function main() { var distance = parseInt(readLine(), 10); //your code goes here distance /40 *60; console.log(distance) }
14th Jan 2021, 5:19 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
0
function main() { var distance = parseInt(readLine(), 10); //your code goes here return distance /40 *60; }
14th Jan 2021, 5:08 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
0
XXX thank you! It finally worked. 😊👍
14th Jan 2021, 5:44 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
- 1
The trip planner project
14th Jan 2021, 5:08 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
- 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
14th Jan 2021, 5:19 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
- 1
Do i need to log the distance? Or i need to create another variable for thw time?
14th Jan 2021, 5:20 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
- 1
14th Jan 2021, 5:20 PM
Brenda Michelle 🌿
Brenda Michelle 🌿 - avatar
- 1
150/40=3.75*60=225
14th Jan 2021, 5:23 PM
Abhay
Abhay - avatar
- 1
I keep getting the same number for input and output. Need help in identifying what im doing wrong?
15th Jan 2021, 4:06 PM
Darren
Darren  - avatar
- 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.
15th Jan 2021, 4:44 PM
Kanji-50
Kanji-50 - avatar