Wednesday 27 April 2016

The Complete Node JS Developer Course - Numbers & If statements

Numbers!


This is getting interesting! In lesson 10 we get to grips with using Maths operators.

We also learn a bit more about variables.

There are two ways to create variables, as illustrated below.

You can create a variable and 'initialize' it with a value, or you can create a variable for use later, and not give it a default value. Well I never! This is another great insider tip that will be needed in the field.



Great stuff!

Increment and Decrement

It can be easy to get disorientated when dealing with Mathematical operators. Here's another great insight that will help when incrementing and decrementing.

Example 1


The following will take the value 24 from the age variable and return 24 + 1, which is 25.


Look at line 5 in our example above, and compare it to the example below. That will perform the same calculation of 24 + 1, and achieve the same result of 25. It is, however, a much neater way of doing the same thing.


The following example will take the same value of 24 from the age value, but this time it will return 24 - 1, which is 23.


Again, if you look at the example below, we see the much neater way of doing the same thing.


When you're first confronted with age++ or age--, it can be intimidating, but when explained properly, it's quite simple really :)

Example 2


Another way to simplify things further is as follows:




So there we have it! Our journey into numbers and variables continues at a pace!

If statements


You can never get too much practice where if statements are concerned!

In lesson 11, because we haven't been introduced to arrays yet, there's lots of practice typing sets of data out the long way. But that's great, because you will need to use, ===!==&& and || in if statements (although not quite so intensively), so it's good to get to grips with what they do.

The course is great because you type along with the instructor as you go along, and then he sets little tasks so you can practice what's just been covered. Programming is such a practical skill so, in the early stages especially, it's a case of use it or lose it. We save each mini project into a file as we progress, so you can look back through the files and see how far you've come.

No comments:

Post a Comment