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
1/14/2021 4:58:38 PM
Brenda Michelle15 Answers
New AnswerWrite inside the existing function . There's a comment like //your code goes here ...Just fill the codes there ...
Brenda Michelle You need to write everything inside the main function because sl calls the main function to start
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,
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)
function main() { var distance = parseInt(readLine(), 10); //your code goes here distance /40 *60; console.log(distance) }
function main() { var distance = parseInt(readLine(), 10); //your code goes here return distance /40 *60; }
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
I keep getting the same number for input and output. Need help in identifying what im doing wrong?
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.
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message