Initializing Variables with the Assignment Operator new

Tell us what’s happening:

I am confused because the hint is showing to use num while the example is using myVar

Your code so far


myVar = 9
// Example
var ourVar = 19;

// Only change code below this line
var a = 9; 
 

Your browser information:

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

Those are just examples to help you understand the format, or syntax of what you need to write.

To complete the challenge, the directions say " Define a variable a with var and initialize it to a value of 9 "

Use the variable name and value given in the instructions, not the ones given as an example.

Variable names can be anything, in your own code, you can use any name you like to help describe what that variable is so that your code is easy to understand. But for the purpose of the challenge, its looking for it to have a particular name.

1 Like

I did copy the format and replace the myVar with a and it didn’t work. I don’t know what to do

Do you still have myVar = 9 above //Example ? That may be why…make sure you only have the line of code from the directions under the line // Only change code below this line

myVar = 9

// Example

var ourVar = 19;

// Only change code below this line

var myVar = a;

a = 9

I took out myVar = 9 and it still gave me error. So I put it back. It says only change code below the line

Hrmm…it should not have been there to begin with…the challenge starts with the line //Example
You also have other extra code on the last line a = 9

Try resetting your challenge to start with a fresh slate, and then only add the one line of code given in the directions, underneath where it says to add it.

The answer was much simpler than I thought. Thanks for the help

Also, maybe this will help. In the example, it defined a variable ourVar with var and initialized it to a value of 19 which is var ourVar = 19

What you need to do is define a variable a with var and initialize it to a value of 9 which is…

A ha! I was typing more hints just as you got it :smiley: Great glad you were able to figure it out! It can be tricky at first…