You may do these challenges all together in one file, or in separate files, according to your preference. You will turn them in all together.
- Create a constant variable called
personAgeand assign it a number between 1 and 100 - Create a constant variable called
isAdultand assign it a boolean expression determining whether that number is above or below 18 - Create a constant variable called
isElderlyand assign it a boolean expression determining whether that number is above or below 60 - Create a template string that will read like this:
Is this person an adult? true. Is this person elderly? false(but fill in the correct variables for true and false) - TIP: Make sure you test by changing the value of
personAgeto make sure it works for children, adults below 60, and adults over 60
- Make
personAgea random number between 0 and 100. (You may want to log the number to make sure your booleans are evaluating correctly!) - Use a conditional statement to log "This person is a child" or "This person is an adult" or "This person is elderly" to the console.
The string function .includes() returns a boolean. It determines whether a string includes a given substring.
let sentence = "This is an example sentence"
let includesExample = sentence.includes("example")
console.log(includesExample) // trueFor this challenge
- create a constant variable called
lyricand assign it your favorite song lyric. - create a constant variable called
includesLoveand assign it a JS expression determining whether your lyric includes the word "love" - do the same thing with the words "heart", "life", "baby", and "yeah".
- create and log a constant variable called
isTypicaland assign it a boolean expression determining whether ANY of the conditions are true - create and log a constant variable called
isVeryTypicaland assign it a boolean expression determining whether ALL of the conditions are true
- Use a conditional statement to log "This song is typical" or "This song is very typical" or "This song is not typical" to the console.
- Find (or write!) a song lyric that meets each condition. Repeat the previous step for each lyric.