I need help on no.25 more variable practice


#1

// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry=("Newyork")

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

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

This is what I have can someone correct me!


#2

var myCountry = "New York"; declared the string new york as the variable myCountry

console.log(myCountry.length); logging the length of the variable to the console. No need for var again as myCountry is already a variable. No " "

console.log(myCountry.substring(0,3)); No need for var again as its a variable. No " " because myCountry is being read by the computer as "New York" so they're not needed


#3

No need to make so many questions. Just one will be enough. Please have a little patients. There are a couple of problems with your code. First off, declaring a variable is simple:

var myCountry = "New York"

now you have a variable (myCountry) which holds a string (New York), a string is just a piece of text. Now, when you can simple log the string stored in myCountry to the console by calling console.log or myCountry:

console.log(myCountry);

Read careful what i just told you, maybe revisit some earlier exercises, and then try to figure out how to do substring correctly


#4

thx I have looked back but still very stuck but thanks for your help anyway


#5

How? I literally gave you the answers with an explanation, as to why you need that code.

Stetim has also done the same but given you just the underlying thing that is required in each sentence


#6

Hi here

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

Inside the console.log you dont need var and the " "
So its should be like that

console.log(myCountry.length );

The same for substring


#7

thx guys for all the help I now understand