Please help with the initializing variables lesson im stuck

Tell us what’s happening:

I just started coding and I am on like the fourth lesson and they are asking me to assign a value of nine to the variable a

anyone know what i am doing wrong please help i don’t know anyone else who codes

Your code so far


// Example
var ourVar = 19;

// Only change code below this line

var a;
var num = 9;
a = 9;

//

anyone know what i am doing wrong please help

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator/

The reason why the challenge is not working is because the rules specify that you need to declare the var a and initialize its value on the same line.

var a = 9;

Try that and it should work.

Hello!

var num = 9;
This is adding a new variable (num) and is not needed.

var a;
a = 9;
This technically works but you are not doing what the challenge is requiring. It wants you to do it all on one line. Try looking at the example they give you.

-J

1 Like

thank u very much that helped right away i would’ve been stuck forever

thank you for helping me out

Tell us what’s happening:

why is c undefinded??

Your code so far


// Initialize these three variables
var a;
var b;
var c;


a = 6;
b = 15;
c = "I am a String!";

// Do not change code below this line

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables

All three variables are defined, but none of them have the right value.
a should be 6, but it is 7.
b should be 15 but it is 20.
c should be “I am a String!” but it is “I am a String! String!”.

Remember that initialising means assigning a value on the same line a variable is declared