Skip to content

js conditionals - #10

Open
Mustafa88A wants to merge 4 commits into
TheCodePeople:mainfrom
Mustafa88A:main
Open

js conditionals#10
Mustafa88A wants to merge 4 commits into
TheCodePeople:mainfrom
Mustafa88A:main

Conversation

@Mustafa88A

Copy link
Copy Markdown

No description provided.

Comment thread ifStatement.js Outdated
// TODO: ADD YOUR CODE BELOW

let userAge = 23;
let minimum=18;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment thread ifStatement.js Outdated
- 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";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Comment thread ifStatement.js Outdated
***********************************************************/
// TODO: ADD YOUR CODE BELOW
let YOUR_NAME = "admin";
let role= 1212;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the role is assigned to "Admin" not a random number

Comment thread ifStatement.js Outdated
console.log("the number is negatine ")

}
else console.log("is zero ");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ifStatement.js Outdated
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let Age=prompt("ENTRE AGE ");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't capitalize the first letter of the first word when naming a variable => age not Age

Comment thread ifStatement.js Outdated
else if (Age < 18) {
console.log("You still have time to register to vote")
}
let younger=18-Age;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
     ....
     }
``` 

Comment thread ifStatement.js Outdated

let Age=prompt("ENTRE AGE ");
if (Age >=18)
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you should use the confirm function as mentioned in the description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants