+ 9

Help with JavaScript challenge 9.4 write code to prove under 21

function main() { var age = parseInt(readLine(), 10) // Your code here }

21st Sep 2021, 2:44 PM
Anthony Oliveri
Anthony Oliveri - avatar
15 Antworten
+ 4
Anthony Oliveri The format of the if is incorrect. If (age < 21) { // your code here...the things you want when true } also your code is outside the main function. The main function code block is within the curly braces... function main () { program code goes here } attention to detail is important. Keep working and you will learn.
21st Sep 2021, 2:58 PM
Paul K Sadler
Paul K Sadler - avatar
+ 4
Cholohatwhite document.write() will not work for the noted challenge because it is testing for output to the console and therefore console.log should be used rather than document.write()
23rd Sep 2021, 3:33 PM
Paul K Sadler
Paul K Sadler - avatar
+ 3
// help function main() { var age = parseInt(readLine(), 10) // Your code here } if (age) (21<1) console.log(false);
21st Sep 2021, 2:47 PM
Anthony Oliveri
Anthony Oliveri - avatar
+ 3
Challenge 9.4 is: "Change Your Password" Challenge 9.3 is: "Find The Adults" And here your task is to check, if the user is 18 or older. Not if user is younger 21!
21st Sep 2021, 4:32 PM
Coding Cat
Coding Cat - avatar
+ 3
Anthony Oliveri The details that Coding Cat [mouse break] points out are important. When you run into problems, check the simple stuff. Don't assume the platform isn't working, rather assume you have made some basic mistake and check things from the start. Make no assumptions. Because assumptions is the mother of all coding bugs
21st Sep 2021, 4:51 PM
Paul K Sadler
Paul K Sadler - avatar
+ 2
Anthony Oliveri Just keep at it. Here is a great Javascript reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
21st Sep 2021, 5:12 PM
Paul K Sadler
Paul K Sadler - avatar
+ 2
Paul K Sadler yeah im briefly looking through it Specifically the control flow and error thats where i was having trouble mostly with { } signs i get the if else statement parts tho
21st Sep 2021, 5:19 PM
Anthony Oliveri
Anthony Oliveri - avatar
+ 2
🤣🤣🤣
21st Sep 2021, 6:05 PM
Anthony Oliveri
Anthony Oliveri - avatar
+ 2
Just to remember, in the time of challenge 9.3 (!), we don't know the conditional statements. You have to solve the challenge by using comparison operator only.
23rd Sep 2021, 10:48 AM
Gabriel
Gabriel - avatar
+ 2
Paul K Sadler ahh ok sure you have reason correction is with the metod log() in this case console.log(answer); thank you for the correction
23rd Sep 2021, 3:51 PM
Cholohatwhite
Cholohatwhite - avatar
+ 1
Anthony Oliveri will u show your attempt First
21st Sep 2021, 2:45 PM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Paul K Sadler your right it was right there its just harder to notice when your thinking in a complicated way thanks!!
21st Sep 2021, 4:53 PM
Anthony Oliveri
Anthony Oliveri - avatar
+ 1
Paul K Sadler been doing a lot on the phone for these past two days, going to learn how to do the heading and how to factor folders when my laptop charges that will defintely come in handy appreciate it!
21st Sep 2021, 5:15 PM
Anthony Oliveri
Anthony Oliveri - avatar
+ 1
interesting but the format of the if is wrong the answer: if(age < 21){ document.write(answer) ; }
23rd Sep 2021, 2:37 PM
Cholohatwhite
Cholohatwhite - avatar
0
The { } define scope function scope if scope loop scope etc. Read 📚 about scope...and I don't mean the mouthwash 😂
21st Sep 2021, 5:41 PM
Paul K Sadler
Paul K Sadler - avatar