Syntax error line 9 lesson 25 Need help with substring


#1



syntax error line 9 substring


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

// Use console.log to print out the length of the variable myCountry.
console.log(var myCountry).length;

// Use console.log to print out the first three letters of myCountry.
console.log('var myCountry').substring(0,3);


#2

Make sure to put the substring inside the console.log statement. You want to log the substring, not log the string and substring the result. Also, you should use myCountry without quotation marks. Otherwise, you would be substringing the literal string "var myCountry" which would become "var".

console.log(myCountry.substring(0, 3));

#3

Thank you so much for the example and your help


#4

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