Skip to content

I finished all the tasks - #12

Open
bit-sercererx wants to merge 1 commit into
TheCodePeople:mainfrom
bit-sercererx:main
Open

I finished all the tasks#12
bit-sercererx wants to merge 1 commit into
TheCodePeople:mainfrom
bit-sercererx:main

Conversation

@bit-sercererx

Copy link
Copy Markdown

No description provided.

Comment thread ifStatement.js
// TODO: ADD YOUR CODE BELOW
let userAge=20
let minDrivingAge=18
if(userAge>minDrivingAge){console.log("the person is old enough to drive");}

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! Please pay attention to your code organization. When you write the block of code for the if statement, it's better to add it in the next line, not right next to the curly brackets. The same goes for the closing bracket. Like this:
if(userAge>minDrivingAge){
console.log("the person is old enough to drive");
}

Comment thread ifStatement.js
let userAge=20
let minDrivingAge=18
if(userAge>minDrivingAge){console.log("the person is old enough to drive");}
else{console.log("the person is not old enough to drive");}

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.

Same here:
else{
console.log("the person is not old enough to drive");
}

Comment thread ifStatement.js
let userName="ameer"
let role="admin"
let username= prompt ('enter your name')
if (userName==username&&role=="admin"){console.log(` Hello ${userName} , and you have permission to access the restricted area.`);}

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.

  1. It's not recommended to use the same variable name with different cases like username and userName as they refer to different values.
    You can differentiate between which refers to which: use clear, concise names like username and usernameInput or enteredUsername.

  2. Also, for the block of code within the curly brackets of the if statement, please write the block of code on the next line, not right next to the curly bracket.
    This makes your code more organized and readable.

Comment thread ifStatement.js
- If the number is zero, print a message saying that it is zero.
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW
let number=2

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.

You're initializing the number variable with a value of 2, but you should be asking the user to input the number. Therefore, you don't need to initialize number at the beginning.

Comment thread ifStatement.js
// TODO: ADD YOUR CODE BELOW
let number=2
let asknumber=prompt("enter a number")
if(asknumber==0){console.log(`it 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.

Please read the task description before jumping directly into the solution. 🙂

Comment thread ifStatement.js
- If the user is younger than 18, the program should calculate how many years are left until they turn 18 and print the message "You will be eligible to vote in X years", where X is the number of years left.
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW
let userage=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.

The variable userage is assigned to 18. Instead, you should prompt the user to input their age and convert the input to an integer as mentioned in the description.

Comment thread ifStatement.js
// TODO: ADD YOUR CODE BELOW
let userage=18
if (userage>=18)
if(confirm("press" )) console.log(`you press ok `);

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.

The nested if-else statements are not properly structured. You need to use curly braces {} to define the block of code for each if-else condition.

The confirmation message within the confirm() function is missing. It should provide some context for the user to make a decision!

Comment thread ifStatement.js
let userage=18
if (userage>=18)
if(confirm("press" )) console.log(`you press ok `);
else(console.log("Why did you waste my time then? 😀."))

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.

The block of code within the else statement should be wrapped with curly brackets {}, not parentheses. Like this:
else {console.log("Why did you waste my time then? 😀.") }

There's a missing calculation for the number of years left until the user turns 18 if they are younger than 18.

Comment thread switchStatement.js
case "Pisces":`(February 19 - March 20):
Horoscope: Your sensitivity and intuition are heightened today, Pisces. Pay attention to your dreams and emotions, as they may hold important messages for you. Take some time for self-reflection and introspection.
`
default:console.log("Sorry, we do not have a horoscope for that sign."); }

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.

Please organize your code better next time:

  • Start the statement of each case in the switch case statement on the next line below the case keyword, not next to it.
  • End the curly bracket below all the switch statements.

Comment thread switchStatement.js
break
default:console.log("Sorry, we do not have recommendations for that weather condition.");
;
}

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.

Please organize your code better next time:

  • remove the extra spaces between line 89 and 90, and 93 and 95

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