More Variable Practice: Exercise 25


#1

Can someone please tell me what is it that I'm doing wrong? I followed the instructions in the comments:


#2

Remove the quotes from around the variable name, myCountry. It is not a string, but a reference to one.

var myCountry = "Canada";
console.log(myCountry.length);

and so on.


#3

@mtf, according to the editor, your code is saying it's wrong. All I'm trying to do is make "myCountry" print out that it is a string.

Do you have anymore suggestions?

All I'm trying to do is perform what the comments are asking me to do...


#4

You're only logging the result of "myCountry".length === 9, which is true, rather than logging the actual length of the variable's value, which would be "America", resulting in 7. You also need to remove the quotes around myCountry in line 9, so that you get the substring of the value of myCountry ("America"), rather than the first three letters of "myCountry":

var myCountry = "America";
console.log(myCountry.length);
console.log(myCountry.substring(0, 3));

#5

Thanks @jibblyj! After a couple of tries in performing of what you said, I got it right. At first, your directions weren't working...


#6

I'm glad you got it working.


#7

Thank you so much! I had this same problem! I am so glad! I finally got to the next lesson! Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :grinning: