Analyzing and Editing Code Walkthrough
score = 82
if (score >= 90)
{
console.log ("You got an A congrats!")
}
else
{
if (score >= 75)
{
console.log ("Please come to retake up to a 90 next week at tutorial!")
}
else
{
console.log ("You have detention!")
}
}
protein = 25
carbs = 36
sugar = 11
if (carbs >= 55 || protein <= 20 || sugar >= 15)
{
console.log ("Your lunch is too unhealthy, please pick a new one")
}
else
{
if (carbs < 35 || protein < 25)
{
console.log ("This lunch is alright but try to add some more carbs or protein")
}
else
{
if (sugar >= 11)
{
console.log ("Looks great but lets see if we can cut down on sugar, we don't want diabetes!")
}
else
{
console.log ("Amazing, you created a healthy lunch!!!")
}
}
}
Your Activites:
Write a program that fits these conditions using nested conditionals:
- If a person has at least 8 hours, they are experienced
- If a person is experienced their salary is 90k, if they have ten hours or above their salary 150k
- If a person is inexperienced their salary is always 50k
- print the salary of the person at the end and whether they are experienced or not
Write a program that fits these conditions using nested conditionals:
- If the product is expired, print "this product is no good"
- If the cost is above 50 dollars, and the product isn't expired, print "this product is too expensive"
- If the cost is 25 dollars but under 50, and the product expired, print "this is a regular product"
- If the cost is under 25 dollars, print "this is a cheap product"
hours = 8
if (hours < 8)
{
console.log ("Inexperienced, Salary is 50k.")
}
else
{
if (hours >= 10)
{
console.log ("Experienced, Salary is 150k.")
}
else
{
console.log ("Experienced, Salary i909.")
}
}