Understand programming I - Variables

in #steemit7 years ago

Since my last post about how i made my first game i was inspired to make this one. This is going to be a little series (i am not sure how long we will see) about programming (mostly about JavaScript but it can be applied in almost all languages) and how can you understand it. In this part i am gonna talk about VARIABLES.

The first and the most important questions - What are variables?

Variables are containers for storing value or data.In each example i will show picture and code in JavaScript for it

Imagine a variables as a box:

Now we made a box(variable) called Variable.In that box you can store numbers, letters,words,sentences,even this whole post!

So what is their use?

So we already imagined variable as a box and we stored number 4835771 in it and called that box "number". Now we want to use that number 4835771 in our code. Now, instead of typing that number we put word "number" in our code. In that way we don't have to type anything that is repetitive.

Variables can also be used to control things in your video game or code. Now imagine that we stored a switch in our box. It can be turned on and off and also turn on and off lights. Now imagine if that we put that switch in our code for example when we open the door in our game switch turns on and also turns on light, and when we exit light turns off. That kind of variable is called "boolean" and it can be true or false.

Without variables 80% of programming wouldn't be possible and it would be very slow. I hope you understand programming with variables a little more.Next time i will talk about variable privacy and a bit about functions.


If you liked this give it an upvote it means a lot to me :)
Until next time bye o/







Sort:  

Fun post good use of visuals. When I teach someone I try to do the same.

Thanks tga1108. I wanted to simplify everything as more as i can. Thanks for support :)

you did a good job.

Coin Marketplace

STEEM 0.21
TRX 0.13
JST 0.030
BTC 67164.91
ETH 3518.77
USDT 1.00
SBD 2.71