2.1 KiB
2.1 KiB
id, title, challengeType, videoUrl, forumTopicId
id | title | challengeType | videoUrl | forumTopicId |
---|---|---|---|---|
56533eb9ac21ba0edf2244aa | Understanding Uninitialized Variables | 1 | https://scrimba.com/c/cBa2JAL | 18335 |
Description
undefined
. If you do a mathematical operation on an undefined
variable your result will be NaN
which means "Not a Number". If you concatenate a string with an undefined
variable, you will get a literal string of "undefined"
.
Instructions
a
, b
, and c
with 5
, 10
, and "I am a"
respectively so that they will not be undefined
.
Tests
tests:
- text: <code>a</code> should be defined and evaluated to have the value of <code>6</code>.
testString: assert(typeof a === 'number' && a === 6);
- text: <code>b</code> should be defined and evaluated to have the value of <code>15</code>.
testString: assert(typeof b === 'number' && b === 15);
- text: <code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"
testString: assert(!/undefined/.test(c) && c === "I am a String!");
- text: You should not change code below the specified comment.
testString: assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code));
Challenge Seed
// Initialize these three variables
var a;
var b;
var c;
// Do not change code below this line
a = a + 1;
b = b + 5;
c = c + " String!";
After Test
(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = '" + c + "'"; })(a,b,c);
Solution
var a = 5;
var b = 10;
var c = "I am a";
a = a + 1;
b = b + 5;
c = c + " String!";