-
Notifications
You must be signed in to change notification settings - Fork 22
I finished what I could from the tasks #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,13 @@ Note: | |
| ************************************************************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
|
|
||
| let userAge = 30 | ||
| let minDrivingAge = 18 | ||
|
|
||
| if (userAge >= minDrivingAge){ | ||
| console.log("You are old enough to get a driver's license"); | ||
| } else{ | ||
| console.log("You are not old enough to get a driver's license")} | ||
| /************************************************************************************************ | ||
| Task 2 (if..else Statement): (15 pts) 👨🏽💼 | ||
| Create a program that checks if a person is an admin, using just if...else statement. | ||
|
|
@@ -33,7 +40,14 @@ Steps: | |
| - If either of the conditions is false, print the message Hello ${enteredUsername}, I'm sorry but it seems you're not authorized to access the restricted area. | ||
| ***********************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
|
|
||
| let userName = "Baneen" | ||
| let role = "Admin" | ||
| let enteredUsername = prompt("What is your name?"); | ||
| userName = enteredUsername; | ||
|
|
||
| if (enteredUsername.toLowerCase().trim() == userName && role.toLowerCase().trim() === "admin"){ | ||
| console.log(`Hello ${enteredUsername}, and you have permission to access the restricted area`) | ||
| }else {console.log(`Hello ${enteredUsername}, I'm sorry but it seems you're not authorized to access this restricted area.`)} | ||
| /************************************************************************************************ | ||
| Task 3 (if..else Statement): (20 pts) 🔢 | ||
| Write a program that checks if a number is positive, negative or zero, using if...else statement. | ||
|
|
@@ -47,7 +61,15 @@ Steps: | |
| - If the number is zero, print a message saying that it is zero. | ||
| ************************************************************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
| let enteredNumber = prompt("Add a number and I'll tell you if it's positive, negative or zero") | ||
|
|
||
| enteredNumber = (enteredNumber) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean: |
||
|
|
||
| if (enteredNumber > 0){ | ||
| console.log ("Positive Number detected") | ||
| }else if(enteredNumber < 0){ | ||
| console.log("Negative Number detected")} | ||
| else {console.log("The number is zero")} | ||
| /************************************************************************************************* | ||
| Task 4 (Nested if..else Statement): (15 pts) 👵🏼 | ||
|
|
||
|
|
@@ -60,6 +82,13 @@ Steps: | |
| ************************************************************************************************/ | ||
| // TODO: ADD YOUR CODE BELOW | ||
|
|
||
| userAge = prompt("What's your age?") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the variables keyword: |
||
| const legalAge = 18 | ||
| userAge = Number(userAge) | ||
|
|
||
| if (userAge > legalAge){ | ||
| confirm("Would you like to continue?") | ||
| } | ||
| /************************************************************************************************* | ||
| Task 5 (if..else Statement): (100 pts) 🍕 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Conditionals</title> | ||
| </head> | ||
| <body> | ||
| </head> | ||
| <body> | ||
| <script src="./ifStatement.js"></script> | ||
| <!-- <script src="./switchStatement.js"></script> --> | ||
| </body> | ||
| <script src="./switchStatement.js"></script> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you reassign the userName to enteredUsername? The purpose of this is to compare the two, so when you assign them to each other, the comparison becomes useless.