Coding Bytes: Part 1 — (Intro &) Data Types
Intro
I’ve been learning coding on / off for about 2 years now. Fallen off the wagon plenty of times. The resources available nowadays are much better and more available compared to a couple of years back and though I still consider myself a newbie, I know my way around things a little better now. I know what may be causing an issue and know where to try and look to fix it.
I’m still rubbish at algorithms but that is a part of my journey that I know I will work through eventually. It’s been a tough ride, especially at the beginning. Even though there is enough support online, getting stuck can be a nightmare! Fixing a problem that’s solution is in your face can sometimes take hours, but I’ve come to accept that as part of the learning process too. I believe that is the hardest part in the beginning — resolving the issue on your own and trying not to give up. I’ve also come to peace with the fact that I may learn/work slower than others, and no matter what I do, I can’t learn everything. Most people will tell you imposter syndrome is too prevalent but the only thing to do is stick through it.
It is often said that the best way to learn is to teach something. And though I have a lot to learn still, I wanted to start a series to solidify my learning, and work through the very basics of programming whilst benefitting someone else learning to code (I hope!). I’ve decided on a format which aimed at reducing information overload and hence named it ‘coding bytes’. The idea is small bits of information can be digested easier and when put together with the other pieces, the magic will happen!
In each post I will aim to cover one subject/concept without linking it to any other principle or subject. In this way I hope, a learner can take small steps and work through the journey reducing the imposter syndrome.
Preamble…
I will be using Javascript as the chosen programming language (don’t worry, all languages are essentially the same!), just because of its ease of use and the fact that it works straight out of the box from your browser. I have made a video showing how you can do this here.
Basic Data Types
The most basic information we deal with is known as a ‘data type’. All this means is the type of data we are going to work with e.g. a letter, a word, or a paragraph can be used as real world examples of data types. In programming we use the following data types (with examples):
Integer
An integer is a positive or negative number. 4 or -12
Float
A number with a decimal. 3.75
Though in Javascript integer
and float
come under the common number
type, I have separated them intentionally as these terms are common many other languages.
String
A word or sentence or more. As string can include numbers too. Note the quotation marks that encapsulate the string. “string”
“this is also a string”
Boolean
A boolean is a true
or false
output. Sometimes true is also known as 1
and false as 0.
Other Data Types
Variables
Variables can be explained as a reusable word or box which we can use to store information and later update it. There are a few ways to declare variables, but we’ll stick with the most basic var
.
var age = 4;
In the the above declaration, I am letting the computer know I wish to declare a variable by using the var
keyword, then calling the variable ‘age’. Now we have variable named age
with a value of 4
. The reason for assigning values will become apparent as we progress.
Arrays
The easiest way to describe arrays are to think of a list or collection of something. A to-do list is an array. The list itself is the array, whilst each to-do item is an array element. Note our array is stored in a variable named ‘list’.
var list = ["pick up shopping", "call the doctor", "book tickets"];
There are a few more data types, but these should do fine for now as this post has become a little longer than I wanted due to the intro.
Thanks for reading. To keep up with my coding journey come say hi 👋 on twitter. I can be found on @lawyerscode