Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Variables Null and Undefined

Need help with this challenge!

I don't know what to do with this challenge. I know the identical() method it's been called out to do what?

<!DOCTYPE html>
<html lang="en">
    <title> JavaScript Foundations: Variables</title>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
    <script src="ignore_this.js"></script>
    <h1>JavaScript Foundations</h1>
    <h2>Variables: Null and Undefined</h2>

    <div id="container">


        var myUndefinedVariable;
        var myNullVariable = null;

        if(myNullVariable == myUndefinedVariable) {
            identical(typeof myUndefinedVariable === "undefined");


1 Answer

Colin Bell
Colin Bell
29,679 Points

It's just asking that you use the strict equality operator. Try using === instead of == with the original code.

if (myNullVariable === myUndefinedVariable) {

This is because:

null == undefined is true

null === undefined is false

And if you're looking for things to be identical, you don't want null and undefined to be equal.