Need help with Variables lesson!


This is my code and it keeps returning the length and substring of myCountry, and not the variable, America. What am I doing wrong?

// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = "America";

// Use console.log to print out the length of the variable myCountry.

// Use console.log to print out the first three letters of myCountry.


myCountry is a variable not string .
so you should write like

console.log(myCountry.length); // without quotes

console.log(myCountry.substring(0,3)); // same here


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