25. I was defining the variable on the line after "console.log"


#1

var myCountry = "insert country here"
console.log( myCountry.length );

var myCountry = "insert country here"
console.log( myCountry.substring(0, 3) );

That should work

The problem with my code was, that I was defining the variable on the line after "console.log",
so what I understood was, that you should first define the variable and then start working with it. :smiley: Pretty obvious, but it took me a few resets to figure it out. Good luck : )


25.More variable practice.Can you please help me?
#2

That works but wouldn't it be a good idea to input a country name in here instead of the predefined text? (just for clarity)


#3

The predefined text is:

// 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( );

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

So, the "insert country here" should still work as it will be seen as a string regardless.


#4

I know, but I said wouldn't it be more readable if it was actually a country name, like "England" rather than "insert country here"


#5

A post was split to a new topic: 25. "USA".substring(0,3)