+ 9
Help with JavaScript challenge 9.4 write code to prove under 21
function main() { var age = parseInt(readLine(), 10) // Your code here }
15 Answers
+ 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.
+ 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()
+ 3
// help
function main() {
var age = parseInt(readLine(), 10)
// Your code here
} if (age) (21<1)
console.log(false);
+ 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!
+ 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
+ 2
Anthony Oliveri Just keep at it. Here is a great Javascript reference
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
+ 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
+ 2
🤣🤣🤣
+ 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.
+ 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
+ 1
Anthony Oliveri will u show your attempt First
+ 1
Paul K Sadler your right it was right there its just harder to notice when your thinking in a complicated way thanks!!
+ 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!
+ 1
interesting but the format of the if is wrong
the answer:
if(age < 21){
document.write(answer) ;
}
0
The { } define scope function scope if scope loop scope etc. Read 📚 about scope...and I don't mean the mouthwash 😂