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


Justin Rose
Justin Rose
12,842 Points

Null and Undefined: Javascript issue: opening assignment

When following and starting the lesson, i downloaded the new files associated with the lesson and open my console after i drag the index.html file from the folder to the browser to open the url. The problem is when i refresh the page when i refresh the page i dont see anything in the console. I thought it was supposed to say " var myVar; undefined "i dont see this in the console is myscript.js connected?

any help would be appreciated

thank you

Hi Justin,

Edit: I just found it. I'll post again when I have a better understanding of the problem and solution.

Can you please post a link to the lesson and I'll check it out?

1 Answer

When I downloaded the lesson files, all the code was already typed - and yes, the index.html file does have a link to myscript.js

Once the Web page is open, open the console by pressing F12. You should see true true If all on separate lines.

When the page loads, here is the relevant JavaScript that produces that output:

var myVar;

// undefined = true; 

console.log(typeof myVar === "undefined");
console.log(myVar === undefined);

var x = null;

if(myVar == null){
} else {

After watching the video, everything seems to be in order.

The only thing you should see in the console is what gets passed into console.log().

// these are equality checks being passed into console.log()
// the result will print true or false to the console
console.log(typeof myVar === "undefined");
console.log(myVar === undefined);