JS help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JS help

I'm stuck on a lesson and need help. It's lesson 9.2,a practice. I have to make all test cases green, but I'm lost. I don't know what I'm doing wrong. I've spent 2 days on this. Can someone please help? function main() { var age = parseInt(readLine(), 20) // Your code here console.log(age >= 10) } It's JUST test case 1. Cases 2, 3, and 4 are all good. I'm not sure what I'm doing wrong.

10th Jun 2022, 9:08 AM
Quientin Fuller
Quientin Fuller - avatar
18 Answers
+ 4
Quientin Fuller Yay! I'm glad you were able to do so! Sometimes you just need additional pairs of eyes to question your own logic. Happens to me everyday. 😁
10th Jun 2022, 9:53 AM
Justice
Justice - avatar
+ 4
Why do people who repeat what I say get mark best? 😂😂 I pointed out the hint 25 minutes ago bahaha. But that's alright, still glad you got the needed help.
10th Jun 2022, 9:57 AM
Justice
Justice - avatar
+ 3
Quientin Fuller Oh, my then it has to do with you changing the boilerplate code. You should never really change the boilerplate. Also while I agree with you about the under 21 thing (I would actually argue under 25 but that's neither here or there either), the task hint wants you to use 18. So if you were using 21 instead, that's why you were failing task one because it wants ages 18-20 to also be printed as an adult.
10th Jun 2022, 9:32 AM
Justice
Justice - avatar
+ 3
Quientin Fuller Can you share you new code please? Otherwise we are a bit blind LOL.
10th Jun 2022, 9:49 AM
Justice
Justice - avatar
+ 2
var age = parseInt(readLine(), 10) // the original task you changed the radix in parseInt method to 20 The radix is the number of values for a single digit. Hexidecimal would be 16. Octal would be 8, Binary would be 2, decimal will be 10. look at the given hint below the sample output to correct your adult check
10th Jun 2022, 9:23 AM
Mohamed
Mohamed - avatar
+ 2
Quientin Fuller Hey buddy, you need to read the answer from M O H A M E D . I think you thought the number following readLine() was the value of the age variable.
10th Jun 2022, 9:31 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
My apologies. Boilerplate means the given code. Also, are you sure it says expected true? It's supposed to expect false and I would attribute that to the fact that you have anything over the age of 10 returning true.
10th Jun 2022, 9:38 AM
Justice
Justice - avatar
+ 2
I figured it out. Thank you Justice M O H A M E D
10th Jun 2022, 9:50 AM
Quientin Fuller
Quientin Fuller - avatar
+ 2
the given hint in the task no more to say If the user is 18 or older, they’re considered an adult. console.log(20>18) outputs true.
10th Jun 2022, 9:52 AM
Mohamed
Mohamed - avatar
+ 1
Hi, I'm a little confused. Are you talking about the adults task? Why do you think adulthood starts at 10?
10th Jun 2022, 9:24 AM
Justice
Justice - avatar
+ 1
I am talking about the adult task. That number is only the after plugging in random numbers and nothing worked. That's just kind of where I left it.
10th Jun 2022, 9:26 AM
Quientin Fuller
Quientin Fuller - avatar
+ 1
It's saying "input 15, expected output true, my output false" I don't even have 15 tired in. You and Mohammed are using terms I haven't read in any lessons yet. Boilerplate? I'm getting more confused.
10th Jun 2022, 9:36 AM
Quientin Fuller
Quientin Fuller - avatar
+ 1
this the original task, You are not supposed to change it function main() { var age = parseInt(readLine(), 10) // Your code here } then read the full task and the given hint write your solution code according to the given hint then it should work fine with no errors focus at the hint its already have the answer.
10th Jun 2022, 9:46 AM
Mohamed
Mohamed - avatar
+ 1
Justice M O H A M E D https://imgur.com/a/r94fOmf Last time I ran it, both numbers were set to 20, and it's still giving me this
10th Jun 2022, 9:46 AM
Quientin Fuller
Quientin Fuller - avatar
+ 1
M O H A M E D okay, I changed the forest number back to 10, but now test case 3 is wrong
10th Jun 2022, 9:48 AM
Quientin Fuller
Quientin Fuller - avatar
+ 1
Quientin Fuller You confirmed my answer in the screenshot. In your screenshot is says Input: 15 Your Output: True Expect Output: False You have to change the given age back to 18 like the hint expects you to. If you keep it at 10, it will return true for the age 15. It needs to return false because 15 is NOT an adult.
10th Jun 2022, 9:48 AM
Justice
Justice - avatar
0
M O H A M E D So it's has nothing to do with the fact that ages 10-17 would be seen as adult? /genuine-question (sorry I can't seem to make that question sound less rude 😅)
10th Jun 2022, 9:27 AM
Justice
Justice - avatar
0
No, under 21 is a child in my opinion, but that's neither here nor there. The numbers I posted above are just numbers I plugged in. After it didn't work, I just started trying random numbers.
10th Jun 2022, 9:29 AM
Quientin Fuller
Quientin Fuller - avatar