Am stack with more variables


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

console.log("myCountry"%0 );


Remember how to get the length of a string?


// 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
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:

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));


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