Complete the code to check if a number is positive.
if (number [1] 0) { console.log('Positive number'); }
We use the greater than symbol > to check if the number is more than zero, meaning positive.
Complete the code to print 'Even' if the number is divisible by 2.
if (number [1] 2 === 0) { console.log('Even'); }
The modulus operator % gives the remainder. If remainder is 0 when divided by 2, the number is even.
Fix the error in the condition to check if age is 18 or older.
if (age [1] 18) { console.log('Adult'); }
We use >= to check if age is 18 or more, meaning adult.
Fill both blanks to check if a number is between 10 and 20 (inclusive).
if (number [1] 10 && number [2] 20) { console.log('Between 10 and 20'); }
Use >= to check number is at least 10, and <= to check number is at most 20.
Fill all three blanks to create an if-else that prints 'Child', 'Teen', or 'Adult' based on age.
if (age [1] 12) { console.log('Child'); } else if (age [2] 19) { console.log([3]); } else { console.log('Adult'); }
Use < to check if age is less than 12 for 'Child'. Then <= 19 for 'Teen'. Else print 'Adult'.