In lesson 25 i keep getting "SyntaxError: missing before statement"


#1


this is my code for lesson 25 learning Java
var my country = "Canada";
console.log(my country.length );
console.log(my country.substring (0,3) );

If somebody can help me to understand what i am doing wrong it would be appreciated'


Replace this line with your code.


#2

you can't have a space in your variable name.

you could use a _

var my_country

from w3school:

JavaScript Identifiers

All JavaScript variables must be identified with unique names.

These unique names are called identifiers.

Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).

The general rules for constructing names for variables (unique identifiers) are:

  • Names can contain letters, digits, underscores, and dollar signs.
  • Names must begin with a letter
  • Names can also begin with $ and _
  • Names are case sensitive (y and Y are different variables)
  • Reserved words (like JavaScript keywords) cannot be used as names

#3

after changing the first line of my code i now get this

Oops, try again. Did you declare a variable called myCountry?


#4

can you please post your update code?


#5

this is my complete code of 3 lines

var mycountry = "Canada";
console.log(mycountry.length );
console.log(mycountry.substring(0,3) );

hope this helps


#6

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

you have mycountry


#7

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