Lesson 25 (everyting is good, seems like bug or smth)


#1

https://www.codecademy.com/courses/getting-started-v2/4/2?curriculum_id=506324b3a7dffd00020bf661#

Guys, dont know what im doing wrong. Any help will be great!

Apearing erros is - Oops, try again. It looks like you didn't log the first 3 letters of myCountry to the console.


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

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

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


#2

in JS is common practice to use camelcase for variable name:

myCountry

but the first letter is lowercase, so the m should be lowercase


#3

I'M HAVING THE SAME PROBLEM.

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

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

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


#4

here:

console.log("mycountry".substring(0,3));

you should get substring of mycountry variable


#5

You need a capital "C", change that your problem should be solved @bruno172008hotmail.c

JavaScript is case sensitive. :slight_smile:

Just want to mention this, you can have spaces for string too.
ie:
var myCountry = "United States Of America"
var myCountry = "UnitedStatesOfAmerica"
var myCountry = "unitedstatesofamerica"

To computer, the above are all same, a string within " " quote. (If I'm not mistaken, correct me if I'm wrong, newb here too)


#6

Hi @palexale, as I have created a topic regarding lowerCamelCase and PascalCase

here

I don't think that having your own code var MyCountry vs the instruction requirement var myCountry is wrong per se (if that is your preference for your own code). Moreover, you have been fairly consistently using var MyCountry throughout your code:

var MyCountry = "Ukraine";
console.log(MyCountry.length);
console.log(MyCountry.substring(0,3));

But, in that exercise, it requires you to create a variable named myCountry not MyCountry. So in this case, I don't think it's a bug.

My thoughts:
Codecademy system check for myCountry as the variable, not MyCountry.
As var myCountry and var MyCountry is totally two different variables in JavaScript. So the detection system won't let you pass.

I've copied your code and see what error it throws out.

Changing every capital M to small letter m will let you pass, because the system look for myCountry instead of MyCountry.

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


#9

have the same variable name you talked about (myCountry), same error message


#10

please post your code


#11

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

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

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


#12

moreover, in the console it said "Rus" which is what it was supposed to be


#13

look at the comment:

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

you don't log the length, you just log the country.

the error message is also alerting you to this issue, its not talking about substring


#14

thanks) all good now


#15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.