How To Learn To Code – A Complete Guide – Part 2

In the previous post, we spoke about what coding is, what the best methods of learning it are and 4 of the 5 elements that make it up. I will summarize here these points very briefly before I continue on to give you the 5th and final element of code. Functions. 

For a more in-depth walk-through of the above, please take a look at the previous post.

What Coding Is

Coding is essentially giving directions to a computer. 

This is done similarly to the way in which you would give directions to a person who was trying to get somewhere. 

The medium through which these directions are transmitted is via the coding language. For the purposes of this post, we will be using a language called ‘JavaScript’.

In every coding language, there are 5 key elements that make it up. In a similar way to how, within a normal spoken language there are elements such as words, numbers, punctuations, etc.

Within the context of coding, those elements are Strings, Numbers (Integers & Floats), Variables, Conditional Statements and Functions.

For a refresher on the 4 previous elements, please take a look at the previous post.

Let’s now go over the method of thinking that is most effective to adopt when learning to code. 

How To Learn To Code

The best mindset to adopt when learning to code is to have the belief while gaining the knowledge of it that the act of coding is fundamentally something that you already know. 

Which is in fact, actually is. 

As we mentioned above, coding is simply the act of giving directions to a computer. 

Giving directions in and of itself is something that you have probably been doing since you were a young child. So within the context of coding for a computer, you will not have to learn that again. 

What you will have to learn is simply the language. And learning a language is a lot less great of an undertaking than learning a new style of thinking. Although coding will indeed, change your thinking for the better, over time.

While learning to code, the key driver will be your understanding that grasping it is just a matter of practice and layering. The brain cannot help but learn when you consistently persist through failure. 

Eventually, you WILL understand. If you persist.

Now, let’s get to Functions. The fifth and final element of all coding languages.

Functions – The Fifth Element Of Code

If we define coding as being the act of giving directions to a computer. Then a program can be described as a stored collection of directions that have been given to a computer. With that knowledge in mind, the best way to think about functions is as mini-programs within the context of the larger programs that they live in.

Functions are collections of directions, formulated in the coding language in a certain way that it understands.

I recommend, once again, re-reading the first post here before we jump into the upcoming example. 

The typical style of writing functions, within the context of the JavaScript language is as so:


var x = myFunction(4, 3);   // Function called, return value will end up in x variable

function myFunction(a, b) {

if (a != b)


  return “The product of variables a and b is: ”a * b + “.”;


// Function returns the product of a and b, wrapped within a string.



What you see here is first, the definition of the variables ‘x’ that we will use as a representative of our function.

On the next line, we have our actual function definition. It has the parameters ‘a’ and ‘b’, which are basically placeholders that represent the values that we will put inside of our function when we are running it. Running it is done as an ‘alert’, as seen above, which is also a function.

The function above simply describes the basic framework and supporting elements of our function.

The function directions themselves that we are actually running are placed within our curly braces.

All of the codes that are within those braces are the set of directions that our function holds, and that will be run when we run our function within the ‘alert()’ function above.

The function will return the outcome of the set of directions that are set within it. In this case, the product is a + b, providing that a and b do not hold the same value.

Conclusion And Summary – A Program Is Simply A Collection Of Functions (And Things That Are Like Them)

In the same way that an essay is simply a collection of paragraphs, a program, likewise, is simply a collection of functions. 

The building blocks that we have described within the first post are what ultimately are used to create the directions that we place within our function. 

With this knowledge, both from the foundation we built in the first post, and in the final element of functions that we have covered here, you can now move ahead and build on this knowledge base in order to further deepen your understanding of programming, and, ultimately, become the coder that you’d like to one day be. 

Good luck on your journey and let me know in comments if you have any questions or queries at all!

Read Part 1 of this article:

How To Learn To Code – A Complete Guide – Part 1

About the Author

Tapha is the Founder of, a simple tool that brings your entire web & mobile UI/UX design planning process into one simple place. He also maintains a blog at FromToSchool, that helps experienced developers learn new languages and frameworks faster, by leveraging the languages and frameworks that they already know. He has taught over 200 young, ambitious Gambians how to code via his live coding class called CodeClass Gambia


  1. You pose some very helpful tips in this article. My current project is elaborating on a lot of these tools, and think that the points you make will be extremely helpful for many. I’m going to share this via my twitter in consideration of the fact that I think it could be quite helpful for up and coming programmers. Thanks for your insights, I look forward to seeing what you produce in the future

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.