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
46 changes: 45 additions & 1 deletion ifStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ Note:
You can change the value of the age variable to test different cases.
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

// const userAge =20;
// const minDrivingAge =18;

// if(userAge >= minDrivingAge){
// console.log("the person is old enough to drive");
// }else{
// console.log("the person is not eligible to get a license yet");
// }
/************************************************************************************************
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 @@ -34,6 +41,17 @@ Steps:
***********************************************************/
// TODO: ADD YOUR CODE BELOW


const userName ="mohamed";
let userTest = prompt("enter user name");
const role ="Admin";
if(userName.toLowerCase() ===userTest && role.toLowerCase() === "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.

You have to lowercase the user input userText, not the constant name userName
No need to lowercase the role

console.log(`Hello : ${userTest} you have permission to access the restricted area`);
}else{
console.log(`Hello ${userTest} I'm sorry but it seems you're not authorized to access the 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 @@ -48,6 +66,17 @@ Steps:
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let number =prompt("enter the number");
let testValue =parseInt(number)

if (testValue > 0){
console.log("that it is positive ");
}else if(testValue < 0){
console.log("that it is negative");
}else{
console.log(" that it is zero");
}

/*************************************************************************************************
Task 4 (Nested if..else Statement): (15 pts) 👵🏼

Expand All @@ -59,6 +88,21 @@ Steps:
- 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
// const oldUser = prompt("enter your age")
// const checks =confirm("Press a button!\nEither OK or Cancel.");


if (oldUser >=18){
if(checks == true){
console.log("Great! You are all set to vote.");
}else{
console.log("Why did you waste my time then? 😀.");
}
}else{
let minAge =18 - oldUser
console.log(`You will be eligible to vote in ${minAge} years`);
}


/*************************************************************************************************
Task 5 (if..else Statement): (100 pts) 🍕
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>
<body>
<script src="./ifStatement.js"></script>
<script src="switchStatement.js"></script>
<!-- <script src="./switchStatement.js"></script> -->
</body>
</html>
68 changes: 68 additions & 0 deletions switchStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,59 @@ Steps:
*Note: Check the file called "Zodiac_Signs.md" to find the list of horoscope messages.*
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW
// let zodiacSign = "Cancer"


switch(zodiacSign){
case "Aries" :
console.log("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("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("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("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("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("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("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("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("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("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("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("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;
}


/************************************************************************************************
Task 6 (Switch Statement): (20 pts)
Expand All @@ -39,3 +92,18 @@ 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 forecast for today");

switch(weather){
case "rainy":
console.log("Recommendations: Wear a waterproof jacket, boots, and bring an umbrella");
break;

case "sunny":
console.log("Recommendations: Wear sunscreen, a hat, and sunglasses");
break;

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