Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.