diff --git a/Clothing_Recommendations.md b/Clothing_Recommendations.md new file mode 100644 index 0000000..33033bf --- /dev/null +++ b/Clothing_Recommendations.md @@ -0,0 +1,40 @@ +## Weather: Sunny + +Recommendations: + +1. Choose lightweight cotton, linen, rayon, chambray, or silk fabrics for breathability and comfort. +2. Opt for light colors and loose-fitting styles to reflect heat and allow air circulation. +3. Wear appropriate sun protection, such as a wide-brimmed hat and sunglasses, and apply sunscreen. +4. Stay hydrated and enjoy the sunny weather in comfortable and breathable clothes! + +## Weather: Rainy + +Recommendations: + +1. Choose waterproof or water-resistant fabrics like polyester, nylon, or Gore-Tex for maximum protection. +2. Synthetic blends are also a good option for their water-repelling properties. +3. Avoid absorbent fabrics like cotton or silk that can become heavy when wet. +4. Consider treated fabrics that are coated with a water-repellent finish. +5. Pair rain gear with appropriate footwear and rain accessories as needed to stay dry in rainy weather. + +## Weather: Cloudy + +Recommendations: + +1. Layer with lightweight knits, fleece, or flannel for easy adjustment to changing temperatures. +2. Choose breathable fabrics like cotton, bamboo, or modal for comfort. +3. Opt for moisture-wicking fabrics like polyester or nylon to stay dry in light drizzle or humidity. +4. Consider fabrics with stretch for flexibility and comfort during activities. +5. Don't forget to have a light jacket or coat made of weather-resistant materials for added protection from wind or light rain. + Being prepared with versatile fabrics and layering options can help you stay comfortable in changing weather conditions during cloudy days! + +## Weather: Snowy + +Recommendations: + +1. Insulating fabrics like fleece, down, or synthetic insulation for warmth. +2. Waterproof or water-resistant fabrics like Gore-Tex, nylon, or polyester to stay dry. +3. Moisture-wicking fabrics like polyester or merino wool to keep you dry. +4. Layering fabrics such as thermal knits, fleece, or merino wool for insulation. +5. Windproof fabrics like nylon or softshell materials for protection from wind chill. + Prioritize warmth, insulation, moisture management, and wind protection when dressing for snowy weather, and be sure to layer appropriately to stay warm and dry in snowy conditions! diff --git a/README.md b/README.md index 8cb8d58..a3c1ca4 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,23 @@ # Conditionals in JavaScript + This repository contains a set of tasks to practice conditionals in JavaScript, specifically if..else and switch statements. ## Getting Started -To get started, please follow the instructions below: -## Fork this repository by clicking on the "Fork" button on the top right corner of the page -1. Clone the repository to your local machine by running git clone `` in your terminal -2. Navigate to the folder name using the cd command in your terminal -3. Open the conditionals.js file in your code editor and start working on the tasks +To get started, please follow the instructions below: -## Task List -The `conditionals.js` file contains a set of tasks each with its description and steps. Please read and follow the steps carefully to complete each task. +1. Fork this repository by clicking on the "Fork" button on the top right corner of the page +2. Clone the repository to your local machine by running git clone in your terminal. Replace with the actual URL of the repository. +3. Navigate to the cloned repository using the cd command in your terminal. This should be the folder that contains the switchStatement.js and ifStatement.js files. +4. Open the ifStatement.js file in your code editor and start working on the tasks related to if-else statements. +5. Open the switchStatement.js file in your code editor and start working on the tasks related to switch statements. +6. Follow the instructions provided in the task descriptions to complete each task. +7. Make sure to work on both files and complete all the tasks in both files. ## Submitting the Task + After completing the tasks, please follow the instructions below to submit your work: + 1. Run git add . in your terminal to track the changes 2. Run git commit -m "" to stage the changes 3. Run git push to push the changes to your forked repository @@ -22,7 +26,9 @@ After completing the tasks, please follow the instructions below to submit your Please note that you must fork the repository before cloning it. ## Resources + Here are some resources that you may find helpful: + - [MDN Web Docs: Conditional Statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling#conditional_statements) - [W3Schools: JavaScript Switch Statement](https://www.w3schools.com/js/js_switch.asp) - [FreeCodeCamp: JavaScript Switch Statements Explained with Examples](https://www.freecodecamp.org/news/fall-through-in-javascript-switch-statements/) diff --git a/Zodiac_Signs.md b/Zodiac_Signs.md new file mode 100644 index 0000000..d94e4c3 --- /dev/null +++ b/Zodiac_Signs.md @@ -0,0 +1,35 @@ +1. Aries (March 21 - April 19): + 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. + +2. Taurus (April 20 - May 20): + 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. + +3. Gemini (May 21 - June 20): + 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. + +4. Cancer (June 21 - July 22): + 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. + +5. Leo (July 23 - August 22): + 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. + +6. Virgo (August 23 - September 22): + 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. + +7. Libra (September 23 - October 22): + 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. + +8. Scorpio (October 23 - November 21): + 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. + +9. Sagittarius (November 22 - December 21): + 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. + +10. Capricorn (December 22 - January 19): + 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. + +11. Aquarius (January 20 - February 18): + 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. + +12. 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. diff --git a/ifStatement.js b/ifStatement.js index 1f99e4b..f44b048 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -1,129 +1,244 @@ -/* Task 1 (if..else Statement): Create a program that checks if a person is old enough to drive, - using an if statement.*/ +/************************************************************************************************ +Task 1 (if..else Statement): (10 pts) 🪪 + Create a program that checks if a person is old enough to drive, using an if statement. + +Steps: + 1. Define a variable named `userAge` to store the person's age. + 2. Define a variable named `minDrivingAge` to store the minimum driving age in your country. + 3. Write an if statement that checks whether the person's age is greater than or equal to the minimum driving age. + - If the person's age is greater than or equal to the minimum driving age, print a message saying that the person is old enough to drive. + - If the person's age is less than the minimum driving age, print a message saying that the person is not eligible to get a license yet. + +Note: + You can change the value of the age variable to test different cases. +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +let userAge = 17; +let 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. + +Description: + In this task, you will create a program that checks if a person is an admin, using just if...else statement. + You will define two variables, `userName` and `role`, and assign them the values "Hamza" and "Admin" respectively. + Then, you will check if the person's userName is equal to "Hamza" and their role is equal to "Admin". + If both conditions are true, you will print a message saying that the person has permission to enter. + Otherwise, you will print a message saying that they are not allowed to enter. + +Steps: + 1. Define two variables username and role, and assign them the values "YOUR_NAME" and "Admin" respectively. + 2. Ask the user to enter his/her name and store it in a variable called enteredUsername. (use the prompt function) + 3. Check if the entered username is equal to YOUR_NAME and the role is equal to Admin. + - If both conditions are true, print the message Hello ${enteredUsername}, and you have permission to access the restricted area. + - 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 = "Hamza"; +let role = "admin"; + +let enteredUsername = prompt("Enter your name: ") +let your_role = prompt("Enter your role: ") + +if (enteredUsername === userName && your_role === role) { + 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 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. + +Steps: + 1. Ask the user to enter a number. + 2. Convert the input to a float or integer. + 3. Write an if...else statement to check whether the number is positive, negative or zero. + - If the number is positive, print a message saying that it is positive. + - If the number is negative, print a message saying that it is negative. + - If the number is zero, print a message saying that it is zero. +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +let number = prompt("Enter a number: ") +number = parseInt(number); + +if (number === 0) { + console.log("this number is zero"); + +} else if (number % 2 != 0){ + console.log("this number is odd"); + +}else { + console.log("this number is even"); + +} + + +/************************************************************************************************* +Task 4 (Nested if..else Statement): (15 pts) 👵🏼 + +Steps: + 1. Create a program that prompts the user for their age and checks if they are old enough to vote. (Note: don't forget to convert the input into an integer) + - If the user is 18 or older, the program should ask if they would like to continue to the voting part or not (Hint: Use the confirm() function). Store the answer in a variable called confirmation. + - If they press "OK", the program should print the message "Great! You are all set to vote." + - If they press "Cancel", the program should print the message "Why did you waste my time then? 😀." + - 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 age = 17 + +if (age >= 18) { + let confirmation = confirm("If you wish to continue voting or not, please enter either OK or Cancel") + + if (confirmation) { + console.log("Great! You are all set to vote."); + + }else{ + console.log("Why did you waste my time then?"); + + } + +} else { + let remainingLife = 18 % age; + console.log(`You will be eligible to vote in ${remainingLife} years`); +} + + +/************************************************************************************************* +Task 5 (if..else Statement): (100 pts) 🍕 + +Description: + You are building a pizza ordering system. + The system should ask the user to select a pizza size, toppings, and drinks. + The total cost of the order should be calculated and displayed to the user. + The system should also apply discounts based on the user's order. + - If the user selects a small pizza, the cost is $10. + - If the user selects a medium pizza, the cost is $15. + - If the user selects a large pizza, the cost is $20. + - If the user adds more than 2 toppings, they receive a 10% discount on their order. + - If the user orders a drink, they receive a $2 discount on their order. + - If the user orders both more than 2 toppings and a drink, they receive a 15% discount on their order. + +Steps: + Step 1: Ask the user to select a pizza size (small, medium, large) + - Use the prompt() method to ask the user to input the pizza size. + - Use the toLowerCase() method to convert the user input to lowercase for easier comparison. + - Store the user input in a variable called size. + + Step 2: Set the base price based on the pizza size + - Create a variable called price. + - Use an if-else-if statement to compare the size variable with the pizza sizes and set the price variable accordingly. (10, 20, 30) + - If the user input is not a valid pizza size (small OR medium OR large), log an error message to the console. (Please select a valid price) + + Step 3: Ask the user to select toppings + - Use the prompt() method to ask the user to input the toppings they want, separated by commas. + - Use the split() method to split the user input into an array of toppings. + - Store the array of toppings in a variable called toppings. + + Step 4: Calculate the cost of the toppings + - Create a variable called toppingCost. + - Use an if-else statement to check the length of the toppings array and calculate the toppingCost accordingly. + - If the length of the toppings array is less than or equal to 2, multiply the length by 2 to get the toppingCost. + - If the length of the toppings array is greater than 2, multiply the length by 2 and then multiply by 0.9 to get the toppingCost . + + Step 5: Ask the user if they would like to add a drink + - Use the prompt() method to ask the user if they want to add a drink to their order. + - Use the toLowerCase() method to convert the user input to lowercase for easier comparison. + - Store the user input in a variable called drink. + + Step 6: Calculate the cost of the drink + - Create a variable called drinkCost. + - Use an if statement to check if the user wants to add a drink. + - If the user wants to add a drink, set the drinkCost variable to 2. + + Step 7: Calculate the total cost of the order + - Create a variable called totalCost. + - Add the price, toppingCost, and drinkCost variables together to get the totalCost. + + Step 8: Apply discounts based on the user's order + - Use if-else-if statements to check if the user qualifies for any discounts. + - If the user adds more than 2 toppings and orders a drink, apply a 15% discount to the totalCost. + - If the user adds more than 2 toppings, apply a 10% discount to the totalCost. + - If the user orders a drink, subtract $2 from the totalCost. + + Step 9: Display the total cost of the order to the user + - Use the console.log() method to display the totalCost variable to the user in the form of a string. + - Use the toFixed() method to format the totalCost to 2 decimal places. +*************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +//step 1 +let size = prompt("Enter the pizza size ").toLowerCase(); + + +//step 2 +let price ; + +if (size === "large") { + price = 20; +} + else if(size === "middle") { + price = 15; + +} +else if(size === "small"){ + price = 10; +} +else { + console.log("Please enter a valid entry"); +} + + +//step 3 +let toppings = prompt("Enter the toppings separated by commas:"); + toppings = toppings.split(','); + + +//step 4 +let toppingCost ; + +if (toppings.length <= 2) { + toppingCost = toppings.length * 2; + +} else { + toppingCost = toppings.length * 2 * 0.9; +} + +console.log(toppingCost); +//step 5 +let drink = prompt("do you need drinks enter yes or no").toLowerCase; + + +//step 6 +let drinkCost = 0; + +if (drink === "yes") { + drinkCost = 2; +} + +//step 7 +let totalCost =price + drinkCost + toppingCost; + +//step 8 +if (toppings.length > 2 && drink === "yes") { + totalCost = totalCost - (totalCost * 0.15); + +} else if(toppings.length > 2){ + totalCost = totalCost - (totalCost * 0.1) ; + +} else if(drink === "yes"){ + totalCost -= 2; +} + +console.log(`The total price of your order $ ${totalCost.toFixed(2)}`); -//Steps: - -//1 Define a variable to store the person's age. - -//2 Define a variable to store the minimum driving age in your country. - -//3 Write an if statement that checks whether the person's age is greater than or equal to the minimum driving age. - -//4 If the person's age is greater than or equal to the minimum driving age, print a message saying that the person is old enough to drive. - -//5 If the person's age is less than the minimum driving age, do nothing. - -// Note: You can change the value of the age variable to test different cases. If the person's age is less than the minimum driving age, nothing will be printed. - -/***********************************************************/ -/* Task 2 (if..else Statement): Create a program that checks if a person is an admin, using just if...else statement.*/ - -/* Description: In this task, you will create a program that checks if a person is an admin, - using just if...else statement. - You will define two variables, userName and role, and assign them the values userName and Admin respectively. - Then, you will check if the person's userName is equal to userName and their role is equal to Admin. - If both conditions are true, you will print a message saying that the person has permission to enter. - Otherwise, you will print a message saying that they are not allowed to enter. -*/ - -// Steps: - -//1 Define two variables userName and role, and assign them the values YOUR_NAME and Admin respectively. - -//2 Ask the user to enter their name. - -//3 Check if the entered userName is equal to YOUR_NAME and the role is equal to Admin. - -//4 If both conditions are true, print the message Hello ${userName}, you have permission to access the restricted area. - -//5 If either of the conditions is false, print the message Hello ${userName}, I'm sorry but it seems you're not authorized to access the restricted area. - -/***********************************************************/ -/* Task 3 (if..else Statement): Write a program that checks if a number is positive, negative or zero, using if...else statement.*/ - -// Steps: - -//1 Ask the user to enter a number. - -//2 Convert the input to a float or integer. - -//3 Write an if...else statement to check whether the number is positive, negative or zero. - -//4 If the number is positive, print a message saying that it is positive. - -//5 If the number is negative, print a message saying that it is negative. - -//6 If the number is zero, print a message saying that it is zero. - -/***********************************************************/ -/* Task 4 (if..else Statement): Create a program that prompts the user for their age and checks if they are old enough to vote. - If the user is 18 or older, the program should ask if they are registered to vote. - If they are registered, the program should print the message "Great! You are all set to vote." - If they are not registered, the program should print the message "You still have time to register to vote."*/ - -// 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. - -/***********************************************************/ -/* Task 5 (if..else Statement): You are building a pizza ordering system. -The system should ask the user to select a pizza size, toppings, and drinks. -The total cost of the order should be calculated and displayed to the user. -The system should also apply discounts based on the user's order.*/ - -// If the user selects a small pizza, the cost is $10. - -// If the user selects a medium pizza, the cost is $15. - -// If the user selects a large pizza, the cost is $20. - -// If the user adds more than 2 toppings, they receive a 10% discount on their order. - -// If the user orders a drink, they receive a $2 discount on their order. - -// If the user orders both more than 2 toppings and a drink, they receive a 15% discount on their order. - -// Steps: -/* Step 1: Ask the user to select a pizza size -- Use the prompt() method to ask the user to input the pizza size. -- Use the toLowerCase() method to convert the user input to lowercase for easier comparison. -- Store the user input in a variable called size. -*/ -/* Step 2: Set the base price based on the pizza size -- Create a variable called price. -- Use an if-else-if statement to compare the size variable with the pizza sizes and set the price variable accordingly. -- If the user input is not a valid pizza size, log an error message to the console. -*/ -/* Step 3: Ask the user to select toppings -- Use the prompt() method to ask the user to input the toppings they want, separated by commas. -- Use the split() method to split the user input into an array of toppings. -- Store the array of toppings in a variable called toppings. -*/ -/* Step 4: Calculate the cost of the toppings -- Create a variable called toppingCost. -- Use an if-else statement to check the length of the toppings array and calculate the toppingCost accordingly. -- If the length of the toppings array is less than or equal to 2, multiply the length by 2 to get the toppingCost. -- If the length of the toppings array is greater than 2, multiply the length by 2 and then multiply by 0.9 to get the toppingCost . -*/ -/* Step 5: Ask the user if they would like to add a drink -- Use the prompt() method to ask the user if they want to add a drink to their order. -- Use the toLowerCase() method to convert the user input to lowercase for easier comparison. -- Store the user input in a variable called drink. -*/ -/* Step 6: Calculate the cost of the drink -- Create a variable called drinkCost. -- Use an if statement to check if the user wants to add a drink. -- If the user wants to add a drink, set the drinkCost variable to 2. -*/ -/* Step 7: Calculate the total cost of the order -- Create a variable called totalCost. -- Add the price, toppingCost, and drinkCost variables together to get the totalCost. -*/ -/* Step 8: Apply discounts based on the user's order -- Use if-else-if statements to check if the user qualifies for any discounts. -- If the user adds more than 2 toppings and orders a drink, apply a 15% discount to the totalCost. -- If the user adds more than 2 toppings, apply a 10% discount to the totalCost. -- If the user orders a drink, subtract $2 from the totalCost. -*/ -/* Step 9: Display the total cost of the order to the user -- Use the console.log() method to display the totalCost variable to the user in the form of a string. -- Use the toFixed() method to format the totalCost to 2 decimal places. -*/ diff --git a/index.html b/index.html index b54da61..f3f4832 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,13 @@ - - - - + + + + Conditionals - - - - - \ No newline at end of file + + + + + + diff --git a/switchStatement.js b/switchStatement.js new file mode 100644 index 0000000..45f2cda --- /dev/null +++ b/switchStatement.js @@ -0,0 +1,135 @@ +/************************************************************************************************ +Task 5 (Switch Statement): (20 pts) + Write a program that takes in a user's zodiac sign and outputs a horoscope for the day. + +Example: + - Enter your zodiac sign: Scorpio + - Your horoscope for the day: You will have a pleasant surprise today in your career. + ------------------------------------ + - Enter your zodiac sign: Gemini + - Your horoscope for the day: You may feel like you are in a rut today. Try doing something out of your comfort zone to break the monotony. + +Steps: + 1. Create a variable named `zodiacSign` and assign its value to a zodiac sign of your choice. + 2. Create a switch statement that checks the value of the sign. + - For each case, write a horoscope message for that sign for the day. + - If the user enters a sign that is not recognized by the switch statement, display an error message saying "Sorry, we do not have a horoscope for that sign." + +*Note: Check the file called "Zodiac_Signs.md" to find the list of horoscope messages.* +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +let zodiacSign = "Aries"; + +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; + default: + console.log("Sorry, we do not have a horoscope for that sign."); + +} + +/************************************************************************************************ +Task 6 (Switch Statement): (20 pts) + Create a program that helps you decide what to wear based on the weather forecast for the day. + +Steps: + 1. Create a variable named `weather` and assign its value to forecasted weather for the day (e.g. sunny, cloudy, rainy, snowy). + 2. Create a switch statement that checks the value of weather. + - For each case, write a message recommending appropriate clothing for that weather condition. + - If the user enters a weather condition that is not recognized by the switch statement, display an error message saying "Sorry, we do not have recommendations for that weather condition." + +Example: + - What's the weather forecast for today? Rainy + - Recommendations: Wear a waterproof jacket, boots, and bring an umbrella. + ------------------------------------ + - What's the weather forecast for today? Sunny + - Recommendations: Wear sunscreen, a hat, and sunglasses. + +*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 = "Sunny"; + + +switch(weather){ + case "Sunny": + console.log(`Recommendations: + + 1. Choose lightweight cotton, linen, rayon, chambray, or silk fabrics for breathability and comfort. + 2. Opt for light colors and loose-fitting styles to reflect heat and allow air circulation. + 3. Wear appropriate sun protection, such as a wide-brimmed hat and sunglasses, and apply sunscreen. + 4. Stay hydrated and enjoy the sunny weather in comfortable and breathable clothes!`); + break; + + case "Rainy": + console.log(`Recommendations: + + 1. Choose waterproof or water-resistant fabrics like polyester, nylon, or Gore-Tex for maximum protection. + 2. Synthetic blends are also a good option for their water-repelling properties. + 3. Avoid absorbent fabrics like cotton or silk that can become heavy when wet. + 4. Consider treated fabrics that are coated with a water-repellent finish. + 5. Pair rain gear with appropriate footwear and rain accessories as needed to stay dry in rainy weather.`); + break; + + case "Cloudy": + console.log(`Recommendations: + + 1. Layer with lightweight knits, fleece, or flannel for easy adjustment to changing temperatures. + 2. Choose breathable fabrics like cotton, bamboo, or modal for comfort. + 3. Opt for moisture-wicking fabrics like polyester or nylon to stay dry in light drizzle or humidity. + 4. Consider fabrics with stretch for flexibility and comfort during activities. + 5. Don't forget to have a light jacket or coat made of weather-resistant materials for added protection from wind or light rain. + Being prepared with versatile fabrics and layering options can help you stay comfortable in changing weather conditions during cloudy days!`); + break; + + case "Snowy": + console.log(`Recommendations: + + 1. Insulating fabrics like fleece, down, or synthetic insulation for warmth. + 2. Waterproof or water-resistant fabrics like Gore-Tex, nylon, or polyester to stay dry. + 3. Moisture-wicking fabrics like polyester or merino wool to keep you dry. + 4. Layering fabrics such as thermal knits, fleece, or merino wool for insulation. + 5. Windproof fabrics like nylon or softshell materials for protection from wind chill. + Prioritize warmth, insulation, moisture management, and wind protection when dressing for snowy weather, and be sure to layer appropriately to stay warm and dry in snowy conditions!`); + break; + default: + console.log("Sorry, we do not have recommendations for that weather condition."); + break; +} + + diff --git a/swithcStatement.js b/swithcStatement.js deleted file mode 100644 index 30fa75d..0000000 --- a/swithcStatement.js +++ /dev/null @@ -1,40 +0,0 @@ -/* Task 5 (Switch Statement): Write a program that takes in a user's astrological sign and outputs a horoscope for the day.*/ - -// Steps: -//1 Create a variable sign and prompt the user to enter their astrological sign. - -//2 Create a switch statement that checks the value of sign. - -//3 For each case, write a horoscope message for that sign for the day. - -//4 If the user enters a sign that is not recognized by the switch statement, display an error message saying "Sorry, we do not have a horoscope for that sign." - -// Example: -/* -- Enter your astrological sign: Scorpio -- Your horoscope for the day: You will have a pleasant surprise today in your career. ------------------------------------- -- Enter your astrological sign: Gemini -- Your horoscope for the day: You may feel like you are in a rut today. Try doing something out of your comfort zone to break the monotony. -*/ - -/***********************************************************/ -/* Task 6 (Switch Statement): Create a program that helps you decide what to wear based on the weather forecast for the day.*/ - -// Steps: -//1 Create a variable weather and prompt the user to enter the forecasted weather for the day (e.g. sunny, cloudy, rainy, snowy). - -//2 Create a switch statement that checks the value of weather. - -//3 For each case, write a message recommending appropriate clothing for that weather condition. - -//4 If the user enters a weather condition that is not recognized by the switch statement, display an error message saying "Sorry, we do not have recommendations for that weather condition." - -// Example: -/* -- What's the weather forecast for today? Rainy -- Recommendations: Wear a waterproof jacket, boots, and bring an umbrella. ------------------------------------- -- What's the weather forecast for today? Sunny -- Recommendations: Wear sunscreen, a hat, and sunglasses. -*/