Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion ifStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

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.

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.


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.
Expand All @@ -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)

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 mean: enteredNumber = parsInt(enteredNumber)?


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) 👵🏼

Expand All @@ -60,6 +82,13 @@ Steps:
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

userAge = prompt("What's your 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.

Please use the variables keyword: let or const when you want to define a variable:
const userAge, let userAge

const legalAge = 18
userAge = Number(userAge)

if (userAge > legalAge){
confirm("Would you like to continue?")
}
/*************************************************************************************************
Task 5 (if..else Statement): (100 pts) 🍕

Expand Down
16 changes: 8 additions & 8 deletions index.html
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>
79 changes: 79 additions & 0 deletions switchStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,61 @@ Steps:
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let zodiacSign = prompt("Enter your zodiac sign")

switch (zodiacSign) {
case "Aries":
console.log("Horoscope: You're feeling bold and energetic today, Aries! Take advantage of this burst of energy and tackle any challenges that come your way. Your determination and confidence will help you achieve your goals.");
break;

case "Taurus":
console.log("Horoscope: It's a good day to focus on your financial matters, Taurus. Take a look at your budget and make any necessary adjustments. Avoid impulsive spending and save for the future.");
break;

case "Gemini":
console.log("Horoscope: Your social calendar is likely to be full today, Gemini. You're in the mood for socializing and networking. Make new connections and engage in stimulating conversations. Keep an open mind.");
break;

case "Cancer":
console.log("Horoscope: It's time to take care of yourself, Cancer. Pay attention to your emotional well-being and prioritize self-care. Take a break from your usual routine and indulge in some self-nurturing activities.");
break;

case "Leo":
console.log("Horoscope: Your creativity is on fire today, Leo. Express yourself through your artistic pursuits and let your inner child come out to play. Your confidence and charisma will attract attention.");
break;

case "Virgo":
console.log("Horoscope: It's a good day for organizing and decluttering, Virgo. Clean up your physical space and tidy up your thoughts. Focus on practical matters and set achievable goals.");
break;

case "Libra":
console.log("Horoscope: Your diplomacy and charm are in full force today, Libra. Use your skills to resolve conflicts and bring harmony to your relationships. Seek balance and fairness in all your interactions.");
break;

case "Scorpio":
console.log("Horoscope: Your intuition is heightened today, Scorpio. Trust your instincts and delve into your emotions. Explore your subconscious mind and gain insights into your inner workings.");
break;

case "Sagittarius":
console.log("Horoscope: You're in the mood for adventure, Sagittarius. Plan a trip or explore new possibilities. Your optimism and enthusiasm will inspire others, and you may learn something new.");
break;

case "Capricorn":
console.log("Horoscope: It's time to focus on your career goals, Capricorn. Set clear objectives and work diligently towards achieving them. Your hard work and determination will pay off in the long run.");
break;

case "Aquarius":
console.log("Horoscope: Your humanitarian side is in the spotlight today, Aquarius. Engage in activities that promote social causes and make a positive impact. Connect with like-minded individuals and share your innovative ideas.");
break;

case "Pisces":
console.log("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.");
break;

default:
console.log("Enter a valid zodiac sign");
break;
}
/************************************************************************************************
Task 6 (Switch Statement): (20 pts)
Create a program that helps you decide what to wear based on the weather forecast for the day.
Expand All @@ -39,3 +94,27 @@ Example:
*Note: Check the file called "Clothing_Recommendations.md" to find the list of weather forecasts and their corresponding clothing recommendations.*
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let weather = prompt("what's the weather?")

switch (weather) {
case "sunny":
console.log("Choose lightweight cotton, linen, rayon, chambray, or silk fabrics for breathability and comfort.");
break;

case "cloudy":
console.log("Layer with lightweight knits, fleece, or flannel for easy adjustment to changing temperatures.");
break;

case "rainy":
console.log("Choose waterproof or water-resistant fabrics like polyester, nylon, or Gore-Tex for maximum protection.");
break;

case "snowy":
console.log("Insulating fabrics like fleece, down, or synthetic insulation for warmth.");
break;


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