From 09db96918cb4898c97d441c96622ca8976cc4570 Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Sat, 1 Apr 2023 02:54:44 +0300 Subject: [PATCH 01/18] Update README.md --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8cb8d58..545bff2 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,13 @@ This repository contains a set of tasks to practice conditionals in JavaScript, ## 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 - -## 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 folder 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: From a7b3fa79cb69453bdcb442bd90c1dc2467ed91d2 Mon Sep 17 00:00:00 2001 From: zehraaMA Date: Sat, 15 Apr 2023 19:04:08 +0300 Subject: [PATCH 02/18] Refactor the task instructions in ifStatement.js --- ifStatement.js | 253 ++++++++++++++++++++++++------------------------- 1 file changed, 124 insertions(+), 129 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index 1f99e4b..68f97b0 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -1,129 +1,124 @@ -/* Task 1 (if..else Statement): Create a program that checks if a person is old enough to drive, - using an if statement.*/ - -//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. -*/ +/************************************************************************************************ +Task 1 (if..else Statement): + 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 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. If the person's age is less than the minimum driving age, nothing will be printed. +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +/************************************************************************************************ +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 and store it in a variable called . + 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 ${userName}, you have permission to access the restricted area. + - 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. +***********************************************************/ +// TODO: ADD YOUR CODE BELOW + +/************************************************************************************************ +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. + - 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 + +/************************************************************************************************* +Task 4 (if..else Statement): + +Steps: + 1. 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. +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +/************************************************************************************************* +Task 5 (if..else Statement): + +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 + - 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. +*************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW From 1e78d29f18ecff857bd6b336b7a620398fab8c4b Mon Sep 17 00:00:00 2001 From: zehraaMA Date: Sat, 15 Apr 2023 19:05:24 +0300 Subject: [PATCH 03/18] Refactor the task instructions in swithcStatement.js --- swithcStatement.js | 78 ++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/swithcStatement.js b/swithcStatement.js index 30fa75d..b403ed9 100644 --- a/swithcStatement.js +++ b/swithcStatement.js @@ -1,40 +1,38 @@ -/* 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. -*/ +/************************************************************************************************ +Task 5 (Switch Statement): + 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 sign and prompt the user to enter their zodiac sign. + 2. Create a switch statement that checks the value of 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 "Clothing_Recommendations.md" to find the list of weather forecasts and their corresponding clothing recommendations +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW + +/************************************************************************************************ +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. + - 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. +************************************************************************************************/ +// TODO: ADD YOUR CODE BELOW From 354fb5eee23dbb4b9772ed79768451863ba0152e Mon Sep 17 00:00:00 2001 From: zehraaMA Date: Sat, 15 Apr 2023 19:08:16 +0300 Subject: [PATCH 04/18] Add weather forecasts and clothing recommendations in Weather_Forecast_and_Clothing_Recommendations.md --- Clothing_Recommendations.md | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Clothing_Recommendations.md 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! From e5e81c6f61b9c30a8de41dd337d945d7162aa7bc Mon Sep 17 00:00:00 2001 From: zehraaMA Date: Sat, 15 Apr 2023 19:09:09 +0300 Subject: [PATCH 05/18] Add daily horoscopes for each zodiac sign in Daily_Horoscopes.md --- Zodiac_Signs.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Zodiac_Signs.md 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. From 03c1971f0e787c6b57268fe138669ea41a371206 Mon Sep 17 00:00:00 2001 From: zehraaMA Date: Sat, 15 Apr 2023 19:10:48 +0300 Subject: [PATCH 06/18] Update README.md file --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 545bff2..d54c0fa 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # 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: + 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 folder using the cd command in your terminal. This should be the folder that contains the switchStatement.js and ifStatement.js files. @@ -12,7 +15,9 @@ To get started, please follow the instructions below: 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 @@ -21,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/) From a0e10423ed83f66792acf39dadd73c4b031aa212 Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Sat, 15 Apr 2023 22:13:09 +0300 Subject: [PATCH 07/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d54c0fa..a3c1ca4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To get started, please follow the instructions below: 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 folder using the cd command in your terminal. This should be the folder that contains the switchStatement.js and ifStatement.js files. +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. From 822912e47470a423938244acf6061c5ce37e3fbc Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:00:52 +0300 Subject: [PATCH 08/18] Rename swithcStatement.js to switchStatement.js --- swithcStatement.js => switchStatement.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename swithcStatement.js => switchStatement.js (100%) diff --git a/swithcStatement.js b/switchStatement.js similarity index 100% rename from swithcStatement.js rename to switchStatement.js From 5433c7f1691ed6cd17d7749e60411fa4e1135b4a Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:01:29 +0300 Subject: [PATCH 09/18] Update index.html --- index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index b54da61..23aecb3 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ Conditionals - + + - \ No newline at end of file + From 0b328a9e5318fad6db68cbe5ed3ee3ccf3163bc8 Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Wed, 12 Jul 2023 10:55:46 +0300 Subject: [PATCH 10/18] Update ifStatement.js --- ifStatement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifStatement.js b/ifStatement.js index 68f97b0..e5993f8 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -27,7 +27,7 @@ Description: 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 and store it in a variable called . + 2. Ask the user to enter their name and store it in a variable called userName. 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 ${userName}, you have permission to access the restricted area. - 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. From 83a41d87c8a5fd3bf00d13f5678d6377eb82abe2 Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:07:16 +0300 Subject: [PATCH 11/18] Update ifStatement.js --- ifStatement.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index e5993f8..a1c9316 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -26,10 +26,10 @@ Description: 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 and store it in a variable called userName. - 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 ${userName}, you have permission to access the restricted area. + 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. + 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 ${username}, and you have permission to access the restricted area. - 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. ***********************************************************/ // TODO: ADD YOUR CODE BELOW @@ -53,7 +53,7 @@ Task 4 (if..else Statement): Steps: 1. 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 the user is 18 or older, the program should ask if they are registered to vote (Hint: Use confirm() function). - 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. From d5199131fe56a327526755e9beeba96973b25bad Mon Sep 17 00:00:00 2001 From: ZehraaMA <125884625+ZehraaMA@users.noreply.github.com> Date: Wed, 12 Jul 2023 18:39:55 +0300 Subject: [PATCH 12/18] Update ifStatement.js --- ifStatement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index a1c9316..eaf4654 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -29,8 +29,8 @@ 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. 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 ${username}, and you have permission to access the restricted area. - - 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. + - 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 From b25a9ff2a975611bdd0529e715e44407fe952609 Mon Sep 17 00:00:00 2001 From: ZhraaBaharAluloom Date: Sun, 11 Feb 2024 09:33:39 +0300 Subject: [PATCH 13/18] Rewrite some of the tasks instruction --- ifStatement.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index eaf4654..1756fd3 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -1,33 +1,33 @@ /************************************************************************************************ -Task 1 (if..else 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 to store the minimum driving age in your country. + 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. If the person's age is less than the minimum driving age, nothing will be printed. + You can change the value of the age variable to test different cases. ************************************************************************************************/ // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 2 (if..else Statement): +Task 2 (if..else Statement): (20 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 userName and Admin respectively. - Then, you will check if the person's userName is equal to userName and their role is equal to Admin. + 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. + 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. @@ -35,11 +35,11 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 3 (if..else Statement): +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. + 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. @@ -49,19 +49,19 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************* -Task 4 (if..else Statement): +Task 4 (Nested if..else Statement): (30 pts) Steps: - 1. 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 (Hint: Use confirm() function). - - 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." + 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 /************************************************************************************************* -Task 5 (if..else Statement): +Task 5 (if..else Statement): (100 pts) Description: You are building a pizza ordering system. @@ -76,15 +76,15 @@ Description: - 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 + 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. - - If the user input is not a valid pizza size, log an error message to the console. + - 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. From 0c638c7112572cac820c0e74934c093a2747e192 Mon Sep 17 00:00:00 2001 From: ZhraaBaharAluloom Date: Sun, 11 Feb 2024 09:45:17 +0300 Subject: [PATCH 14/18] Rewrite some of the tasks instructionin the switch statment file --- switchStatement.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/switchStatement.js b/switchStatement.js index b403ed9..08aec68 100644 --- a/switchStatement.js +++ b/switchStatement.js @@ -10,20 +10,21 @@ Example: - 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 sign and prompt the user to enter their zodiac sign. - 2. Create a switch statement that checks the value of sign. + 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 "Clothing_Recommendations.md" to find the list of weather forecasts and their corresponding clothing recommendations + +*Note: Check the file called "Zodiac_Signs.md" to find the list of horoscope messages.* ************************************************************************************************/ -// TODO: ADD YOUR CODE BELOW +// TODO: ADD YOUR CODE BELOW /************************************************************************************************ 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). + 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." @@ -34,5 +35,7 @@ Example: ------------------------------------ - 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 +// TODO: ADD YOUR CODE BELOW From 94da4913880bfce5b4702669bf4bb4493c795fe0 Mon Sep 17 00:00:00 2001 From: ZehraaMA Date: Sun, 11 Feb 2024 09:49:38 +0300 Subject: [PATCH 15/18] Add some emojies the if-statement files --- ifStatement.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index 1756fd3..1866c8a 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -1,6 +1,6 @@ /************************************************************************************************ -Task 1 (if..else Statement): (10 pts) - 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. @@ -15,8 +15,8 @@ Note: // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 2 (if..else Statement): (20 pts) - Create a program that checks if a person is an admin, using just if...else statement. +Task 2 (if..else Statement): (20 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. @@ -35,8 +35,8 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 3 (if..else Statement): (20 pts) - Write a program that checks if a number is positive, negative or zero, using if...else statement. +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. @@ -49,7 +49,7 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************* -Task 4 (Nested if..else Statement): (30 pts) +Task 4 (Nested if..else Statement): (30 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) @@ -61,7 +61,7 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************* -Task 5 (if..else Statement): (100 pts) +Task 5 (if..else Statement): (100 pts) 🍕 Description: You are building a pizza ordering system. From 32bff1d089b5b736fe8269be5337f819ef202edc Mon Sep 17 00:00:00 2001 From: ZehraaMA Date: Sun, 11 Feb 2024 09:52:21 +0300 Subject: [PATCH 16/18] rewrite the points of each task --- ifStatement.js | 4 ++-- switchStatement.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index 1866c8a..70a2570 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -15,7 +15,7 @@ Note: // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 2 (if..else Statement): (20 pts) 👨🏽‍💼 +Task 2 (if..else Statement): (15 pts) 👨🏽‍💼 Create a program that checks if a person is an admin, using just if...else statement. Description: @@ -49,7 +49,7 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************* -Task 4 (Nested if..else Statement): (30 pts) 👵🏼 +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) diff --git a/switchStatement.js b/switchStatement.js index 08aec68..79cc6fc 100644 --- a/switchStatement.js +++ b/switchStatement.js @@ -1,5 +1,5 @@ /************************************************************************************************ -Task 5 (Switch Statement): +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: @@ -20,7 +20,7 @@ Steps: // TODO: ADD YOUR CODE BELOW /************************************************************************************************ -Task 6 (Switch Statement): +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: From a67c0ea9e1b12f56c2d7efe5354fd746051313b6 Mon Sep 17 00:00:00 2001 From: Mahdi209 Date: Mon, 12 Feb 2024 00:48:19 +0300 Subject: [PATCH 17/18] first step --- ifStatement.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/ifStatement.js b/ifStatement.js index 70a2570..ee66a7e 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -14,6 +14,14 @@ Note: ************************************************************************************************/ // 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. @@ -34,6 +42,18 @@ Steps: ***********************************************************/ // 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. @@ -48,6 +68,21 @@ Steps: ************************************************************************************************/ // 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) 👵🏼 @@ -60,6 +95,25 @@ Steps: ************************************************************************************************/ // TODO: ADD YOUR CODE BELOW +let age = prompt("enter your age"); + +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) 🍕 From 9406c91770c3e06877884c7fb6a0ceaa2e38113f Mon Sep 17 00:00:00 2001 From: Mahdi209 Date: Mon, 12 Feb 2024 14:20:48 +0300 Subject: [PATCH 18/18] the task is done --- ifStatement.js | 104 ++++++++++++++++++++++++++++++++++++--------- index.html | 18 ++++---- switchStatement.js | 94 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+), 28 deletions(-) diff --git a/ifStatement.js b/ifStatement.js index ee66a7e..f44b048 100644 --- a/ifStatement.js +++ b/ifStatement.js @@ -42,18 +42,18 @@ Steps: ***********************************************************/ // TODO: ADD YOUR CODE BELOW -// let userName = "Hamza"; -// let role = "admin"; +let userName = "Hamza"; +let role = "admin"; -// let enteredUsername = prompt("Enter your name: ") -// let your_role = prompt("Enter your role: ") +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.`); +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. @@ -68,19 +68,19 @@ Steps: ************************************************************************************************/ // TODO: ADD YOUR CODE BELOW -// let number = prompt("Enter a number: ") -// number = parseInt(number); +let number = prompt("Enter a number: ") +number = parseInt(number); -// if (number === 0) { -// console.log("this number is zero"); +if (number === 0) { + console.log("this number is zero"); -// } else if (number % 2 != 0){ -// console.log("this number is odd"); +} else if (number % 2 != 0){ + console.log("this number is odd"); -// }else { -// console.log("this number is even"); +}else { + console.log("this number is even"); -// } +} /************************************************************************************************* @@ -95,7 +95,7 @@ Steps: ************************************************************************************************/ // TODO: ADD YOUR CODE BELOW -let age = prompt("enter your age"); +let age = 17 if (age >= 18) { let confirmation = confirm("If you wish to continue voting or not, please enter either OK or Cancel") @@ -176,3 +176,69 @@ Steps: - 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)}`); + diff --git a/index.html b/index.html index 23aecb3..f3f4832 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - - - - + + + + Conditionals - - - - - + + + + + diff --git a/switchStatement.js b/switchStatement.js index 79cc6fc..45f2cda 100644 --- a/switchStatement.js +++ b/switchStatement.js @@ -19,6 +19,50 @@ Steps: ************************************************************************************************/ // 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. @@ -39,3 +83,53 @@ 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 = "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; +} + +