Help! #25 Variable Practice


Hi! I'm stuck on #25 of the Javascript course.
Here's what I've got:
// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = ("America").length

// 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( "myCountry".substring(0,3));

It's telling me I have a Syntax error: Unexpected Token Var? I don't really know what to do, help would be appreciated!


Hey @megan1441 You have two problems: First your suppose to just store the STRING for the var not the length:

Your Code:

Correct Code:

var myCountry = ("America")

Secondly to get the first three substrings remember its always -1 so it dosent go from 0 to 3 but from 0 to 2.

Your code:

Correct Code:
console.log( "myCountry".substring(0,2));

Hope this helped! If it didnt just reply stating your problem and ill do my best to help you! Cheers!


Thank you! That's helped, i got it :smile:


2 posts were split to a new topic: 25. I'm just confused