Need help with a problem


#1

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

// Use console.log to print out the length of the variable myCountry.
console.log(var myCountry ==== "United States" );
myCountry.substring(0,5)
// Use console.log to print out the first three letters of myCountry.
console.log(United States.substring(0,3));


#2

The above should be your line 3 code. Be sure to use only a single = when making an assignment.

Use console.log() to log the variable...

console.log(myCountry);

This does not indicate string length.

myCountry.length

Now log it.

The above will raise an exception. United is undefined (as is States). To JavaScript they look like identifiers (variable names). Use the variable, myCountry instead.


#3

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