Help guys! SOS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help guys! SOS

I still haven’t figured out what this means var age = parseInt(readLine(), 10); “parseInt(readLine()” this is always coming up in the problems and I don’t even know how or what to do or play around it. Can anybody help? I would appreciate a brief explanation

9th Jan 2022, 9:27 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
14 Answers
0
[That link seems to be a Pro Code Coach task that somehow you have access to without Pro status. I cannot access it.] Code Coach often provides pre-made, working, but incomplete, code to get you started. There is usually a comment that shows where you are to begin filling in the rest of the code to finish the task. For that particular line I gave the long description before. Here it is in short: the readLine() function waits for user input. The user types the input. The input gets converted into a number. The number gets stored into the age variable. Now your task is to use the value in the age variable to implement some logic and make decisions based on age [or so I assume].
10th Jan 2022, 5:51 PM
Brian
Brian - avatar
+ 1
Here an example of a complete solution: function main() { var distance = parseInt(readLine(), 10); //your code goes here console.log(60*distance/40) }
9th Jan 2022, 10:19 PM
JaScript
JaScript - avatar
+ 1
Pxavier readLine() reads a line of text from the console. parseInt(readLine(), 10); takes the line that was passed in from the console and parses out from the string an integer number. The argument, 10, specifies that we are expecting the number to be parsed as a decimal integer. var age = parseInt(readLine(), 10)); takes the decimal integer output from parseInt and assigns it to the age variable.
10th Jan 2022, 5:51 AM
Brian
Brian - avatar
+ 1
Brian ofcourse! I get it now. Thank you
10th Jan 2022, 5:56 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
+ 1
// Try this function instead: function setReminder(x){ console.log("You set a reminder about " + x); }
11th Jan 2022, 7:13 PM
JaScript
JaScript - avatar
+ 1
JaScript Thanks! Alot!!!!!! I’ve figured it out 🤠🤠🤠
11th Jan 2022, 7:20 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
0
The line coded data input for a task. You have to take the variable age and use for a solution.
9th Jan 2022, 9:41 PM
JaScript
JaScript - avatar
0
This occurs in the tasks from a course or code coach with JavaSript. In this way the code is automatically supplied with new test data and then checks the results of the code for correctness.
9th Jan 2022, 10:16 PM
JaScript
JaScript - avatar
0
JaScript okay. So that means when trying to solve any problem Here an example of a complete solution: parseInt(readLine(), 10; The above should be ignored?
9th Jan 2022, 10:27 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
0
Pxavier can you be more detailed about what is your stumbling block? Is it the technical terms or is it a concept?
10th Jan 2022, 4:38 PM
Brian
Brian - avatar
0
Brian I’m trying to solve this https://sololearn.com/coach/392/?ref=app And i dont seem to understand the concept of that expression
10th Jan 2022, 4:42 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
0
Brian JaScript Please what is wrong with this my code?! It keeps saying error ‘fix bug’ 😢😢😢😢😢 Can you help🙏🏿🙏🏿 function main() { var eventExample = readLine(); // function call setReminder(eventExample); } //complete the function function setReminder(eventExample){ console.log("You set a reminder about " + eventExample); } setReminder("workout");
11th Jan 2022, 6:15 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
- 1
JaScript i still dont understand. Am i to ignore “parselnt(readLine()”? Where am i suppose to input the figure?
9th Jan 2022, 9:45 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar
- 1
Brian i still dont understand 🤔🤔🥴🥴
10th Jan 2022, 3:17 PM
Ogu Charles Chukwudi
Ogu Charles Chukwudi - avatar