Problem 25


#1

i cant understand how to do the 25... i dont see the error? or maybe i didnt understand how to do this one!
my code looks like this:
// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = "Los Angeles";

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

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

someone help me please :persevere:


#2

With
var myCountry = "Los Angeles";
you assign
the string Value "Los Angeles"
to the
variable myCountry

OR in other words

you have defined
a variable myCountry with its associated string Value "Los Angeles"

From now on when the Javascript interpreter encounters myCountry
it will get at the associated string Value.

Thus you could use
console.log( myCountry ); ==>output>> Los Angeles
or
console.log( myCountry.length ); ==>output>> 11


#3

You use strings in as arguments of console.log(). And you should use variable.

For example console.log(myCountry).

And if you want to print length of the variable you must use .length on the variable. Not on the console.log() :smile:


#4

What's the answer? I can't seem to get it correctly


#5

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

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

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


#6

Try to use the variable myCountry
and NOT the string Value _'Kenya'
thus
myCountry.length
myCountry.substring(0,3)