What is wrong with this code? basic JS

What am I doing wrong?

Your code so far


// Only change code below this line
var a = 6;
var b = 15;
var c = "I am 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/91.0.4472.77 Safari/537.36 Edg/91.0.864.37

Challenge: Understanding Uninitialized Variables

Link to the challenge:

Hi @asmaa-13

Have you read and understood this instruction?

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

1 Like

I read it but I’m not really sure I’m quite getting it now
can you help please?

The value of a should be set to 5 not 6. That of b should be 10 not 15

but in the area where the test is run it says 6 and 15 that’s why I got confused
Thank you for your help!

you have everything right bent bladi but you didn’t read the comment above they said do not change the code below but you change it.
it must go like this

Moderator Edit: SOLUTION REDACTED

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

This is what the message says
a should be defined and evaluated to have the value of 6 .

What does variable a have to be in order for the expression to evaluate to 6?

a+1=6

That is why the challenge told you to assign the number 5 to variable a.

5+1=6

If you assign the number 6 to variable a then this expression does not make sense anymore.

6+1=6

Does it make sense now why you have to Initialize the three variables a , b , and c with 5 , 10 , and "I am a" ?

Yes it does now! Thanks a lot :slight_smile:

1 Like

thank your for inform me . next i won’t post it .

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