Complete the code to check if the user's age is exactly 18.
if (user.age [1] 18) { console.log('User is 18 years old'); }
= instead of == which assigns rather than compares.!= which checks for inequality.The == operator checks if two values are equal. Here, it checks if user.age is exactly 18.
Complete the code to check if the temperature is greater than 30 degrees.
if (temperature [1] 30) { console.log('It is hot outside'); }
< which checks for less than.== which checks for equality.The > operator checks if the left value is greater than the right value. Here, it checks if temperature is above 30.
Fix the error in the code to check if the score is less than or equal to 100.
if (score [1] 100) { console.log('Score is within limit'); }
=> which is not a valid comparison operator.< which excludes equality.The correct operator for 'less than or equal to' is <=. The option => is invalid syntax.
Fill both blanks to check if the user's score is between 50 and 100 inclusive.
if (score [1] 50 && score [2] 100) { console.log('Score is in range'); }
> instead of >= excludes 50.< instead of <= excludes 100.The condition checks if score is greater than or equal to 50 and less than or equal to 100. So, use >= and <=.
Fill all three blanks to filter users with age greater than 18, score less than 100, and status equal to 'active'.
if (user.age [1] 18 && user.score [2] 100 && user.status [3] 'active') { console.log('User is eligible'); }
!= instead of == for status check.< and > for age and score.The conditions check if user.age is greater than 18, user.score is less than 100, and user.status equals 'active'. So use >, <, and ==.