Can someone explain why var c isn't working?

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

Your code so far


// Only change code below this line
var a = 5;
var b = 10;
var c = " i am a String!";
// Only change code above this line

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36

Challenge: Understanding Uninitialized Variables

Link to the challenge:

Hi @icey1 !

I would suggest adding a console.log to the bottom of your code and you will see why it is not working.

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

console.log(c)

i don’t get it can you give me an example please :pleading_face:

If you added that console.log like I suggested, then you should see this result
Screen Shot 2021-09-11 at 5.02.42 PM

It says, i am a String! String!

That doesn’t make much sense because the correct result should be
I am a String!

Make the necessary changes here so you get the correct output.

Learning how to use console.log is an important of javascript.

Hope that helps!

i did change it but it says:
// running tests

c

should not contain

undefined

and should have a value of the string

I am a String!

// tests completed // console output i am a String! i am a String!

Can I see your new code?

Because this output is still incorrect

// Only change code below this line
var a = 5;
var b = 10;
var c = "i am a";
// Only change code above this line

a = a + 1;
b = b + 5;
c = c + " String!";
console.log(c)

You are almost there.

This part needs to start with a capital I.
Not lowercase.

Once you fix that then the test will pass.

It is important to pass really close attention to detail in programming.

Hope that helps!

omg thank you so much :heart:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.