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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zodiac_Signs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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):
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):
Expand Down
99 changes: 96 additions & 3 deletions ifStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ 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

let userAge = 24;
let minimum = 18;
if (userAge >= minimum) {
console.log(" the person is old to drive");
} else {
console.log(" the person is not old to drive.");
}
/************************************************************************************************
Task 2 (if..else Statement):
Create a program that checks if a person is an admin, using just if...else statement.
Expand All @@ -33,6 +39,14 @@ Steps:
- 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
let your_Name = "admin";
let role = 1212;
let enteredUsername = prompt("give user name");
if (enteredUsername == your_Name && role == 1212) {
console.log("welcam ");
} else {
console.log("I`m sorry");
}

/************************************************************************************************
Task 3 (if..else Statement):
Expand All @@ -47,7 +61,15 @@ Steps:
- If the number is zero, print a message saying that it is zero.
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let number = prompt("enter namber");
let float = parseInt(number);

if (float >= 0) {
console.log("the number is positive ");
}
if (float <= 0) {
console.log("the number is negatine ");
} else console.log("is zero ");
/*************************************************************************************************
Task 4 (if..else Statement):

Expand All @@ -59,7 +81,16 @@ Steps:
- If the user is younger than 18, the program should calculate how many years are left until they turn 18 and print the message "You will be eligible to vote in X years", where X is the number of years left.
************************************************************************************************/
// TODO: ADD YOUR CODE BELOW

let Age = prompt("ENTRE AGE ");
if (Age >= 18) {
let conformion = confirm("you are volte");
console.log(conformion);
console.log("Great! You are all set to vote.");
} else if (Age < 18) {
console.log("You still have time to register to vote");
}
let younger = 18 - Age;
console.log(younger);
/*************************************************************************************************
Task 5 (if..else Statement):

Expand Down Expand Up @@ -122,3 +153,65 @@ Steps:
- Use the toFixed() method to format the totalCost to 2 decimal places.
*************************************************************************************************/
// TODO: ADD YOUR CODE BELOW
let size = prompt(
"Please select the pizza size: small | medium | large :"
)?.toLowerCase();

// Step 2:
let price = 0;
if (size == "small") {
price = 10;
} else if (size == "medium") {
price = 15;
} else if (size == "large") {
price = 20;
} else {
console.log(`please enter a valid size, ${size}`);
size = prompt("Please select the pizza size: small | medium | large :");
}

// Step 3:
let toppings =
prompt(
"Please enter the toppings you want, separated by commas: Mushroom, tomato, olive, onion, garlic, pineapple"
)?.split(",") || [];

// Step 4:
let toppingCost = 0;
if (toppings.length <= 2) {
toppingCost = toppings.length * 2;
} else {
toppingCost = toppings.length * 2 * 0.9;
}

// Step 5:
let drink = prompt(
"Would you like to add a drink to your order? (yes or no):"
)?.toLowerCase();

// Step 6:
let drinkCost = 0;
if (drink === "yes") {
drinkCost = 2;
}

// Step 7:
let totalCost = price + toppingCost + drinkCost;

// Step 8:
let discount = 0;
if (toppings.length > 2 && drink) {
discount = totalCost * (15 / 100);
totalCost -= discount;
// OR totalCost *= 0.85;
} else if (toppings.length > 2) {
discount = totalCost * (10 / 100);
totalCost -= discount;
} else if (drink) {
totalCost -= 2;
}

// Step 9: Wohooooo
console.log(
`Here's your order and the total cost will be: $${totalCost.toFixed(2)}`
);
18 changes: 9 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Conditionals</title>
</head>
<body>
<script src="./ifStatement.js"></script>
<!-- <script src="./switchStatement.js"></script> -->
</body>
</head>
<body>
<!-- <script src="./ifStatement.js"></script> -->
<script src="./switchStatement.js"></script>
</body>
</html>
102 changes: 100 additions & 2 deletions switchStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,78 @@ Steps:
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 zodiac = prompt("enter the tower (Scorpio , Gemini)");
// console.log(zodiac.toLowerCase());

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

case "Gemini":
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 "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 "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):
Expand All @@ -29,10 +101,36 @@ Steps:
- 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? 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
//console.log("Rainy , Sunny , Cloidy , Snowy ")
let weather = prompt(
"enter the forecasted weather for the day (Rainy , Sunny , Cloidy , Snowy)"
);

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

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

case "Cloudy":
console.log("Beware, there is a possibility of rain");
break;

case "Snowy":
console.log("Wear plenty of clothes, it's cold");
break;
default:
console.log(
"Sorry, we do not have recommendations for that weather condition"
);
}