js conditionals - #10
Conversation
| // TODO: ADD YOUR CODE BELOW | ||
|
|
||
| let userAge = 23; | ||
| let minimum=18; |
There was a problem hiding this comment.
Well done!
It's better to use a clear variable name. Here, the name "minimum" doesn't clearly indicate what it refers to. Consider using a more descriptive name such as "minDrivingAge".
| - If either of the conditions is false, print the message Hello ${userName}, I'm sorry but it seems you're not authorized to access the restricted area. | ||
| ***********************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
| let YOUR_NAME = "admin"; |
There was a problem hiding this comment.
YOUR_NAME is not a variable name. It's written in the description to instruct you to add your name as a value, like this:
username = "Mustafa"
| ***********************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
| let YOUR_NAME = "admin"; | ||
| let role= 1212; |
There was a problem hiding this comment.
here the role is assigned to "Admin" not a random number
| console.log("the number is negatine ") | ||
|
|
||
| } | ||
| else console.log("is zero "); |
There was a problem hiding this comment.
This will not work properly because you set the conditions <= and >=, which means greater than or equal to zero. When you enter a zero number, the first condition will be met, and it will not pass to the else statement.
| ************************************************************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
|
|
||
| let Age=prompt("ENTRE AGE "); |
There was a problem hiding this comment.
We don't capitalize the first letter of the first word when naming a variable => age not Age
| else if (Age < 18) { | ||
| console.log("You still have time to register to vote") | ||
| } | ||
| let younger=18-Age; |
There was a problem hiding this comment.
This should be within an else statement, not outside it, as it will print regardless of whether the user is younger than 18 or not.
else {
let younger=18-Age;
....
}
```
|
|
||
| let Age=prompt("ENTRE AGE "); | ||
| if (Age >=18) | ||
| { |
There was a problem hiding this comment.
Here you should use the confirm function as mentioned in the description
No description provided.