Am not sure what I should be doing here


#1

More Variable Practice

We have seen how to create a variable. But how do we use it? It is useful to think that any time you type the variable's name, you are asking the computer to swap out the variable name and swap in the value of the variable.

For example:

var myName = "Steve Jobs";

myName.substring(0,5)

Look at the second line above. You have asked the computer to swap out myName and swap in Steve Jobs, so

myName.substring(0,5)

becomes

"Steve Jobs".substring(0,5)

which evaluates to Steve.

Another example

var myAge = 120;

What is

myAge % 12 ? See the hint to check your answer.

So the variable stores the value of the variable, whether that is a number or a string. As you will see soon, this makes writing long programs much easier!

Instructions

Follow the instructions in the comments in the code to continue.

?

Hint

Note that "New York" and "new york" are seen by the computer to be different strings. (i.e. "New York" is not the same as "new york")

And the answer from above is that myAge % 12 evaluates to 0.

this is what I wrote, am not sure what I should be doing here , or write what on where??

// Declare a variable on line 3 called
// myCountry and give it a string value.
var mycountry= "New York"

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

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


Substrings
#2

you need to search the length of myCountry:

console.log(myCountry.length);

the same as above:

console.log(myCountry.substring (0,3 ));

And remember, i cant just tell you the answers to every lesson, you have to try it on your own.


#3

I didn't want to answer I just didn't understand the question properly, lol and I'll do my best, have you mastered java script or something?

Thanks


#4

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