Fall 2024 - P3
3.5 Booleans; Hacks (Period 3)
Homework hacks for 3.5
Hack 1
- Create a function that determines if you should go outside.
- The function will take in 2 parameters, the temperature and isRaining.
- If the temperature is below 100 degrees and isRaining is true, then the function should return true.
- If the temperature is above 32 degrees and isRaining is false, then the function should return true.
- Otherwise, the function should return false.
Use this template:
function goOutside(temperature, isRaining) {
// Your code here
}
Example:
Javascript:
function goOutside(temperature, isRaining) {
// Your code here
}
Python:
def goOutside(temperature, isRaining):
# Your code here
References:
Hack 2
- Use De Morgan’s Law to create an expression that simplifies the following expressions: ```javascript // Expression 1 let stayInside = !(isRaining && isCold)
// Expression 2 let stayInside = !(isRaining || isCold) ```
- Remember that De Morgan’s Law states that the complement of the union of two sets A and B is equal to the intersection of the complement of the sets A and B.
- Or more simply:
!(A || B) === !A && !B
and!(A && B) === !A || !B