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 trialkeenan
6,764 PointsNeed 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">
<head>
<title> JavaScript Foundations: Variables</title>
<style>
html {
background: #FAFAFA;
font-family: sans-serif;
}
</style>
<script src="ignore_this.js"></script>
</head>
<body>
<h1>JavaScript Foundations</h1>
<h2>Variables: Null and Undefined</h2>
<div id="container">
</div>
<script>
var myUndefinedVariable;
var myNullVariable = null;
if(myNullVariable == myUndefinedVariable) {
identical(typeof myUndefinedVariable === "undefined");
}
</script>
</body>
</html>
1 Answer
Colin Bell
29,679 PointsIt's just asking that you use the strict equality operator. Try using === instead of == with the original code.
if (myNullVariable === myUndefinedVariable) {
identical();
}
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.