25/28 How to use variables


#1

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

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

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


Javascipt 25/28
#2

@devsolver15680,
Have a look at the usage of the variable myCountry.

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

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


#3

what is wrong with mine?


#4

@devsolver15680,
In principal, nothing wrong with your code....
but in this lesson they wanted you to become acquainted
with the usage of variables , in this case the usage of the myCountry variable.


#7

3 posts were split to a new topic: 25. It looks like you didn't log the length of myCountry to the console


#9

Thank you for your input @leonhard_wettengmx_n i value ur opinion.
i sill new in javaScript so i'll take all the help i get im used to HTML n CSS


#12

5 posts were split to a new topic: 25. Just felt like this one was kind of confusing


#16

Good stuff i'm learning a lot here , thank you guys, but i can not grasp JavaScript as well as i did with Html and CSS, this one is really complicated.


#18

2 posts were split to a new topic: 25. There was a problem with your syntax?


#22

This works! Copy and paste it into your box:

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

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

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


#23

It works in the sense that it gets you a pass but with that code you have missed a very important part of learning how to use JavaScript variables.


#24

Wow, thank you for this! It took me reading your answer several times before I finally GOT it!! That was tricky!!!


#25

oh thanks mate it works you are right


#26

That is very true! Sometimes as humans we focas more on winning then on the important part of learning. I went back and did this myself.