From 8d4247ac3f29010cf309fc39773cae84b1040a28 Mon Sep 17 00:00:00 2001 From: JaeMaaroufi Date: Mon, 12 Feb 2024 16:20:38 +0300 Subject: [PATCH] I finished what I could from the tasks if statement (1st, 2nd, 3rd task full while 4th and 5th not..). And for Switch statement I finisehd both tasks successfully --- ifStatement.js | 31 +++++++++++++++++- index.html | 16 +++++----- switchStatement.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 9 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index 70a2570..0ab2f55 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -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) + +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?") +const legalAge = 18 +userAge = Number(userAge) + +if (userAge > legalAge){ + confirm("Would you like to continue?") +} /************************************************************************************************* Task 5 (if..else Statement): (100 pts) 🍕 diff --git a/index.html b/index.html index 23aecb3..4bbc3b9 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - - - - + + + + Conditionals - - + + - - + + diff --git a/switchStatement.js b/switchStatement.js index 79cc6fc..dca555e 100644 --- a/switchStatement.js +++ b/switchStatement.js @@ -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. @@ -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; +} \ No newline at end of file