#1 Learning the basics of JavaScript: variables, arrays, conditional statements and functions

Here’s how to start learning the basics of JavaScript, tailored for total beginners.

I must admit, I’m not a natural at learning to code. It took me about a year to complete the HTML and CSS coding courses on Codeacademy. But it helped me to get my job working in digital at a well-known London university.

When that wasn’t satisfying enough, I also enrolled in an HTML/CSS beginners’ coding course with the amazing Code First: Girls in London. I enjoyed that so much that I also completed their Ruby course, and our project group won the end-of-course competition.

Finally, I also attended a Ruby on Rails day course hosted by Rails Girls in London. And that was the end of my formal training in web development.

Since leaving London, I’ve started to learn Javascript in my quest to become a competent coder. It’s been a mixture of stumbling my way through open-source learn to code platform Free Code Camp (free, as the name suggests) and begging for help from a kind developer friend.

When someone tells me to code something as part of an everyday problem, I’d like to be able to do it. At the moment, my knowledge of coding is piecemeal, fragmented. I want to be the engineer that tinkers under the hood. I want to play with the boys.

This blog post is an attempt to document my journey with learning the basics of JavaScript, to help me learn and retain information. I bought this book to supplement my learning:


DOM Scripting by Jeremy Keith

Before I could properly start learning the basics of JavaScript, I wanted to be able to understand the *point* of JavaScript. I know that HTML is the bones of the internet that we surf, and CSS is the styling that makes it pretty. JavaScript was something I vaguely understood as making the web more dynamic.

But what did this actually mean?

Learning The basics of JavaScript

As far as I can tell, JavaScript was developed as a third language to be used as a standard on web pages to make them interactive. It can be used to do other things like build apps but developers mainly use this language on websites.

The biggest drawback of using JavaScript is accessibility problems for people using outdated browsers, or users with disabilities. And yet nearly every website you encounter only works properly with JavaScript enabled. That is just the nature of the modern web.

So that’s the point of JavaScript, as with so many things on the web. It just *is*, developed by some of the earliest players in the history of the internet (founded by Brendan Eich) and it’s here to stay.

It is a programming language used in the browser, so it doesn’t require communication between the front and back end of a website to work, making it a lot faster than other languages.

JavaScript has been used to build websites such as Facebook and Google. Even though it’s used for lots of things, for the beginner programmer JavaScript can be used in the browser to manipulate web pages.

There are several concepts within JavaScript that are important to learn, and are handy because you can also apply them to other programming languages.

The following four concepts will help you start learning the basics of JavaScript.


A variable is like a container that can be assigned different values. These are useful when you might want to use the same script over and over with different data input into your program. So you wouldn’t want to rewrite the script every time. Users might be inputting data, in which case they can be assigned to your variables. Variables can be named anything you like.


An array is a type of variable that is essentially a list. You might use an array for lots of things in a web browser, such as posts on a blog. In JavaScript, you could tell your script to display the first four items in your array on the front page of your blog. Again, the arrays will have values that can be used in your scripts. An array is simply a way of holding numerous values together.

Conditional statements

The syntax for one of the most common conditional statement is ‘if’ and you can use it to execute a piece of code if a certain condition is met. The condition will either be true or false and for example it could be if a value equals more than a certain number, such as 2. In real life the usage for this in JavaScript could be something like if the time is equal more than a certain hour, to execute a certain pop to say ‘Good morning!’.


A loop is a type of conditional statement that can perform a repetitive task until the script tells it to stop. It’s a variant of an ‘if’ statement which executes some code over and over and includes ‘while’, ‘do…while’ and ‘for’. You want the code to keep going a set number of times, so in real life your JavaScript might be telling the browser to send a certain message as long as a user’s game score stays below a certain level.


A function is a kind of mini-script that you can use to contain code you want to use over and over again. You give your function a name and write the script you want to be executed whenever this function is called. Your function is like a variable in that it can be called anything, like ‘flower’. It can contain variables, arrays and conditional statements, among many other things. Essentially, if you want to keep using the same piece of code in your script, you can wrap it inside a function.


I hope this short run-through will get you started in learning the basics of JavaScript.

As a conceptual learner, I find it much easier to learn something if I can see where it fits into the whole framework. I can’t just learn some JavaScript and make a program. I have to know exactly why we’re doing it.

With this in mind, I’ve been enjoying my email subscription to The History of the Web, where I get stories about milestones in the development of the internet. Since I came late to the party, I don’t have lots of knowledge people assume you know about web history and its purpose.

As you turn every corner in this journey of coding, there is more and more complexity to be unearthed. You can learn to code, but then something like Machine Learning becomes the new difficult skill that will scare mediocre programmers away.

We are haunted by the idea of there being a ‘real programmer’, someone with the innate genius to design the technology that governs our lives. Everyone else is an imposter who should just go home. I’d almost suspect that a big reason JavaScript is criticised so often is because it’s one of the best programming languages for beginners.

It is true that the powers that be will keep moving the goalposts. As soon as lots of women learn to code, that will no longer be ‘enough’ to succeed in technology. We are endlessly behind in the race.

And in learning to code, I encounter endless naysayers who tell me that the language I am learning is useless or not ‘real’. Vague comments are thrown around about just getting a job as a junior developer and learning by experience (erm, I’m a professional blogger and I don’t have time) or questioning why I would even need to learn to code. The answer is that I want to. That the future is filled with technology and women need to join the party.

The road is hard and long. But we remain optimistic. We keep trying. We learn.

This is a great run-through of learning JavaScript from Codementor on Medium. Sign up to their mailing list as they have lots of fantastic coding resources.

I made this Wake on Wakelet which is a collection of resources for learning how to code. I’ll keep adding to it.


About the author

Catherine Heath

I’m a B2B freelance tech blogger and content writer. I have a thing for psychology, diversity, tech and startups. Learning to code.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *