A little confused on variables

Hi, I am on this lesson (https://www.codecademy.com/courses/introduction-to-javascript/lessons/variables/exercises/var

It says on the hint to use newNum, but this doesn’t work (I get a syntax error). I tried looking it up on MDM docs but couldn’t find much info. I have taken a screenshot and wondering if anyone could please help me explain what’s going on here?

Thanks for any help, appreciated.

var newNum

Is just an example where “newNum” is just meant to represent a variable name. That hint is a hint; not a solution. What you have done is correct. The hint is just showing you how to structure the syntax

Variable Name Equals 0

var numericalDigitZero = 0


Thank you very much for the replys. I got myself up to speed on variables and it makes perfect sense what you said. Appreciate the help.

In JavaScript we can declare variables at one point, and define them later.

var a, b, c;

Or in ES6,

let a, b, c;

If we attempt to access these variables no errors will be thrown. We’ll just get, undefined.

Later in our logic we can make assignments to those variables on the fly. We will never need to (or be able to) declare them again. They are defined, however transiently by their assigned values.

let a;    =>  declaration

a = 42    =>  definition

Hi mtf,

Thankyou for the breakdown. Thanks for letting me know about let aswell.

I read that es6 came out a few years ago so its important to know.

All the best

1 Like

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