Need help! On declaring variables


#1

// Declare a variable on line 3 called
// myCountry and give it a string value.

i am having trouble on this can anyone help me?


#2

Declaring a variable in JavaScript is done in one of three ways…

var    |
let    |  variableName = value;
const  |

One can also be defined directly without a keyword but that is not a best practice since the variable does not inherit the scope of its parent function. Instead it inherits the scope of the window object.

More about this will be learned soon, so let this point slide. Always use a keyword to declare a variable and you will not run into any problems.

var myVariable = "string  value";

#3

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