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 trialrays0
16,293 PointsI keep getting an 'Oh no' warning on the Javascript identical() task, everytime i submit. Why is this?
I entered my fix in the code section, and clicked submit, but i get no progress or wrong confirmation. Instead i keep getting a pop up warning that something is wrong.
<!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 = null;
var myNullVariable = null;
if(myNullVariable == myUndefinedVariable) {
identical();
}
</script>
</body>
</html>
1 Answer
Clayton Perszyk
Treehouse Moderator 48,850 PointsChange this:
var myUndefinedVariable = null;
to:
var myUndefinedVariable; // this variable is now undefined
In your condition, you need to use the 'strict equality' operator (===):
if (myNullVariable === myUndefinedVariable) {
identical();
}
Because both null and undefined are falsey values the double equality operator (==) returns true; the triple equality operator (===) will check to see if the two values are identical, and in the case of null and undefined they are not 'strictly' the same value, even though they are both falsey.
rays0
16,293 Pointsrays0
16,293 PointsAppreciate the help Clayton. Is it normal for the website to pop up the 'Oh no' dialog when the solution is wrong? I thought it would just show the red banner (it never showed red or green banners, looked like stuck)?
Clayton Perszyk
Treehouse Moderator 48,850 PointsClayton Perszyk
Treehouse Moderator 48,850 PointsWhen you get the popup, 'Oh no', it doesn't have anything to do with your answer. It just means your request isn't going through. Sometimes closing your browser (or maybe refreshing it) and then reopening it will help; sometimes it's better to try the challenge later. Not sure exactly why it happens, but it isn't indicative of failing code; rely on the green and red banners for whether or not your code is passing.