WDI Fundamentals Unit 8
You should see the following code in the editor window:
var x; /* Your Expression */
If you don't see the JS Bin below, please refresh the page.
1) Write an expression that assigns
x to the variable
value, so long as
x is not
null, the expression should set
value to 100.
x is equal to
undefined when no value has been assigned (e.g.,
var x;), but you could also assign it the value of
var x = null;), and both of these values would be "falsey."
After you click the
run button, you can test this in the console tab by typing
value, and then
return. Test your expression for several different values of
null. does it behave like you expect?
2) Next, replace that expression with one that assigns
undefined, but otherwise assigns 50 (regardless of
x's actual value).
3) Finally, write an expression that assigns
x is an empty string (
'') but otherwise assigns
Were you able to get all of your expressions to work? If so, nice job!
Stuck? Check out the solutions to see what you can do.
Ready for another quiz? Here we go!