Am stack with more variables


#1

<Use console.log to print out the length of the variable myCountry.
console.log(9%1 );.>

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


console.log("myCountry"%0 );


#2

Remember how to get the length of a string?


#3

// declare a variable called myCity and give it a string value
var myCity="New York"
That step is perfect. You have made a new variable and you have given it a string value.

// use console.log to print the length of the variable myCity
console.log("variable")
That step is not so perfect. If you look in the output window, that prints variable, but it should print 8 because that is the length of the value that you have stored as myCity.

You can fix that by changing:

console.log("variable");
to
console.log(myCity.length);
In this final step, you are getting the correct output but you haven't made use of your new variable. This exercise is called More Variable Practice, so let's practice using your variable.

// use console.log to print the first three letters of myCity
See the difference between:

console.log( "New York".substring(0,3));
and
console.log(myCity.substring(0,3));


#4

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