Complete the Comparison
Question
Fill in the blank to check if `value` is not null and not undefined.
Code
const value = "hello";
if (value ___ null && value !== undefined) {
console.log("Has a value");
}
Hint
Use strict inequality to compare against null.
Explanation
value !== null uses strict inequality to check that value is not null. Combined with value !== undefined, this checks that the value is neither null nor undefined. For "hello", both conditions are true, so 'Has a value' is printed. (You could also use value != null which covers both null and undefined with loose equality.)
Related Resources
Related Lessons
- Conditions
Learn about comparison operators.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.