Lesson 25 More Variable Practice Help

Can someone please help it says use the hint but the hint isn’t helping

1 Like


It looks like you are trying to use a variable before defining it. The checker wants you to define the variable first before you use it. You are currently using it on line 3 and defining it on line 4. Define it on line 3 and then use it on line 4 instead.

Next, remember learning about .length - if you add it to a variable, it gives you the length of it’s contents. Instead of making a variable with a static string, log to the console the length of the contents of the variable you created on line 3 -> myCountry.length

Finally, take a look at the last one, think about what exactly you’re telling the computer to do. It’s telling you to get the first 3 letters of myCountry the variable you created, not a string.

Let me know if that works.


I am pretty sure I did this right but it still says I did it wrong



For the first exercise, you’re assigning the variable myCountry the length of the string “Canada” which would be 6. So if you use myCountry it would spit out the value of 6.

You need to assign that only a value, not use the .length string property. (not yet anyways).

For exercise two, I’m not sure why you’re using var in front of myCountry - you already created that variable on line 3. You only need to log the length of the variable, you’re almost there. console.log(myCountry.length);

For the final exercise, you need to print out the first 3 letters of the variable myCountry - again, you’re using a string instead of the variable. I’m happy you tried though! console.log(myCountry.substring(0,3)); is what you should be using instead.

Let me know if that helps :smile:


That Worked thanks :smile:

var myCountry = “Cananda”;

// Use console.log to print out the length of the variable myCountry.

// Use console.log to print out the first three letters of myCountry.
console.log(myCountry.substring(0, 3));
//this is the way i did it and it is green

Hi Alan, we can always use more helpers here, so thank you for responding.

To make the most of your time, try to find questions that aren’t solved yet. Then when you answer them, explain where the user went wrong and what that means when programming in JavaScript. Use @lloan’s response as a good example of helping the new coder learn why.

Don’t worry if you are also a new programmer, answering questions is a great way to make sure that you understand what you are learning.

3 posts were split to a new topic: Lesson 25 More Variable Practice Help

thanks it helped me too

wait WAW??!! @albionsrefuge @hillak33

NVM!!! I’ve figured it out…

2 posts were split to a new topic: 25. it looks like myCountry is not a string" or it says “undefined.”