How to concatenate the undefine string

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


// Only change code below this line
var a=0;
var b=0;
var c=0;

a = 5;
b = 10;
c = undefined;
c= ''+'Iam a';



// Only change code above this line

a = a + 1;
b = b + 5;
c = c + " String!";

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36

Challenge: Understanding Uninitialized Variables

Link to the challenge:

c should not be set to undefined. Please remove that line. You need to set c to ‘I am a’ only. So when it is concatenated with " String!", it reads “I am a String!”.

Also, there should be space between the words, I and am.

1 Like

Initialize the three variables a , b , and c with 5 , 10 , and "I am a" respectively so that they will not be undefined .

You initialized them all to zero which was unnecessary.

And then subsequently redefined them “close” to what they should be as previously mentioned.

You can just initialize the variable like var a = 5; And so on.

Here you redefine c:

And on the next line redefine it again:

Normally setting c to undefined there might not cause a problem but the tests here are looking to check c is not undefined, but you did just that so the test fails.

Also, another thing that might not cause an issue but is unnecessary is assigning a string value to a variable by doing this:

It can just simply be ‘I am a’.