Article series: Learn JavaScript from Scratch

python javascript beginners

Understanding Python's built-in data types as a JavaScript developer

Sunday, March 26, 2023

Learn about Python's built-in data types, including numeric types, sequences, mappings, and sets, and how they compare to their JavaScript counterparts. This article explains the similarities and differences between Python's int, float, complex, str, list, tuple, dict, set, and frozenset data types and the Number, String, Array, Object, and Set types in JavaScript.

javascript exercises beginners

Hoisting differences related to keywords var, let and const in JS

Wednesday, January 27, 2021

We all know that the var keyword should not be used in our code, and that we should mostly use let and const. We've probably already read articles about the reasons for this and how to use them properly. But what are the differences between var, let, and const, in relation to hoisting? Let's find out.

javascript exercises beginners

Find the key code for a keydown or keyup event in JavaScript

Wednesday, January 27, 2021

Key up and key down events in JS return a bunch of information in the Event object. This information includes the keycode data. In this tutorial we discuss how to get that info with JS.

javascript exercises beginners

Using cookies in JavaScript

Tuesday, January 26, 2021

Cookies are one of the oldest ways of saving text-based data on the web. The data that gets saved is not meant to be large. It's use case is to 'remember' some things about the user, even after they have closed the web page or the browser. In this article, we'll learn about working with cookies in JS.

javascript exercises beginners

Convert an object to array in JS

Friday, January 22, 2021

Converting an object to an array is pretty easy in JavaScript. All we have to do is use Object.keys, or an even easier method to use, Object.entries.

javascript exercises beginners

Get an object's length in JavaScript

Thursday, January 21, 2021

To get the length of an object in JS, we use Object.keys() to get an array of our object's own properties' keys. Then we can easily return the length value.

javascript exercises beginners

Build a multi-dimensional array in JavaScript

Monday, January 18, 2021

How to build matrices in JS? Also known as multi-dimensional arrays, these are just arrays of arrays in JS. An easy way to build multi-dimensional arrays is to output them using nested loops, as we'll show in this tutorial.

javascript exercises beginners

Convert kebab case to camel case in JavaScript

Monday, January 18, 2021

It's the combination of String.prototype.match(), RegExp, and String.prototype.replace() that gives us the solution to coverting a kebab case string to camel case string in JS.

javascript exercises beginners

Capitalize the first letter of a string in JavaScript

Monday, January 18, 2021

The trick is to separate the string into the first letter and the rest of the string using charAt() and slice(), then run the toUpperCase() method on the first substring, and concatenate the rest of the original string back to the uppercased first letter.

javascript exercises beginners

Insert CSS styles with JavaScript

Sunday, January 17, 2021

Appending a style tag to the head tag of an HTML document requires some simple DOM manipulation. In this tutorial, we'll discuss how to do this, and all the other ways of adding styles using JS.

javascript exercises beginners

Compute the factorial of a number with JavaScript

Sunday, January 17, 2021

Calculating a factorial is very easy, but many JS implementations online make this problem unnecessarily complex. In this tutorial, we'll see the basics of how to calculate a factorial in JavaScript. We'll also go through the explanation of building a factorial calculating function in JS step-by-step.

javascript exercises beginners

Calculate the Fibonacci sequence in JS

Saturday, January 16, 2021

Fibonacci sequence in JS should not be hard to build. In this article, we show step-by-step, how to build in a few simple steps, a rudimentary fibonacci sequence. Once we know the basic mehanism that lies behind the logic of fibonacci sequence code, we can then build more complex code based on this foundation.

javascript exercises beginners

Count the number of times a substring appears in a string in JavaScript

Friday, January 15, 2021

Have you ever tried to see how many times a letter or a word appears in a string? Or how many times a value is repeated in an array? This tutorial shows you how to figure that out in JS.

javascript exercises beginners

Convert an array of numbers to an array of ordinal numbers in JS

Thursday, January 14, 2021

To format an array of numbers as ordinal numbers, we need to properly add the suffixes -st, -nd, -rd, and -th to correct numbers. This includes numbers 11, 12, and 13, which are a bit of an edge case. In this article, we discuss how this works.

javascript exercises beginners

Format a number as currency in JS

Wednesday, January 13, 2021

Formatting a number as currency in JS is easy. We can use Intl.NumberFormat(), and style it as currency, or we can use the toLocaleString method, and again provide the style parameter to the options object.

javascript exercises beginners

Format a number with comma as a thousands separator in JS

Tuesday, January 12, 2021

In JS, we can add a comma as thousands separator using the toLocaleString() method, or using Intl.NumberFormat().format, or using a RegExp. In this tutorial, we'll cover the first two listed means of doing this.

javascript exercises beginners

Generate a random sub-array from a larger array

Monday, January 11, 2021

To get a random, three-member sub-array from an array of items, we need to use the splice, Math.random, and array flat methods, along with a simple for loop. It's a nice and easy solution, and in this tutorial, we'll go through each step of how to do this.

javascript exercises beginners

Add random CSS classes to a paragraph in JavaScript

Sunday, January 10, 2021

We have a web page with a script tag. That script tag holds an array of various Bootstrap 4 CSS classes, and our JavaScript picks a random member from this array and assigns it as a CSS class to a paragraph in our web page's body tag.

javascript exercises beginners

Generate a random password with JavaScript

Saturday, January 9, 2021

We can easily whip up our own password generator in vanilla JS. This tutorial shows you how to do it, step by step, with each step explained in detail.

javascript exercises beginners

Randomize the order of members in a JavaScript array

Friday, January 8, 2021

Randomly reordering members of a JavaScript array might seem an easy task, but it can also be difficult to junior developers. See a step-by-step solution with a detailed explanation of how to shuffle an array in JS.

javascript exercises beginners

Get a number randomly from a range of numbers in JS

Thursday, January 7, 2021

Math.random() gives us a range between 0 (inclusive) and 1 (exclusive). But how do we use this method to get a random number from a range of numbers, say, a random number between 30 and 60? Read more to find out...

javascript exercises beginners

Randomly return a true or false from a JavaScript function

Thursday, January 7, 2021

Using the conditional (ternary) operator, we are able to easily return, at random, either a boolean true or false in JS. Additionally, by setting up our condition differently, we can affect the frequency of one result over the other. In this article, we explain how this works.

javascript exercises beginners

Pick a random member from a JavaScript array

Wednesday, January 6, 2021

Multiply the length of array with the call to Math object's random method, then floor the result. We'll explain how that's done in this article.

javascript exercises beginners

Emulate a six-sided dice

Tuesday, January 5, 2021

Use Math.random() static method to emulate a pair of dice in JavaScript, and keep in mind these simple tips.

javascript beginners

Objects vs non-objects in JavaScript

Saturday, December 12, 2020

This article discusses the difference between objects and non-objects in the JavaScript language.

css javascript beginners

Replace all instances of a CSS class using vanilla JS

Saturday, March 7, 2020

How to use vanilla JavaScript to replace all instances of a CSS class with another CSS class on a web page? That's what we'll learn in this article.

javascript beginners

The Ultimate List of Productivity Boosters for Developers

Thursday, December 5, 2019

Productivity can be hard to improve, even if you're a talented web developer. Here's a list of tips and tricks that might help you boost your productivity as a web developer.

javascript beginners

Multiplication table using nested for loops

Tuesday, December 3, 2019

Nested for loops in JavaScript can help us with a number of coding tasks. In this article, we'll see how to use it to build a multiplication table and a domain-name generator.

javascript beginners

Working with maps in JavaScript

Monday, December 2, 2019

The map data structure is another data structure in JS that derives from the Object prototype. In this article, we're taking an in-depth look at maps in JS.

javascript beginners

Working with arrays in JavaScript

Monday, December 2, 2019

JS array prototype, array methods, array use cases, and a number of tips and tricks - we're going to cover all of that and more in this in-depth tutorial on arrays in JavaScript.

javascript beginners

Working with sets in JavaScript

Sunday, December 1, 2019

This is an in-depth introduction to sets in JavaScript. A set is a special kind of a collection in JavaScript, holding only unique values.

javascript beginners

Write a simple quiz app in JavaScript

Sunday, November 10, 2019

How to write a very simple quiz app in JavaScript? Find out in this introductory, beginner-friendly tutorial.

javascript beginners

Write a simple todo app in JavaScript

Sunday, November 10, 2019

How to write a very simple todo app in vanilla JavaScript? Find out in this introductory, beginner-friendly tutorial.

javascript beginners

Helpful tricks to learn JavaScript

Friday, November 8, 2019

What are the ways to improve you JavaScript coding skills? How to get better faster? Are there any shortcuts to success? We try to find the answer to these questions and to give some practical tips and tricks in this article.

javascript beginners

What are events in JavaScript

Friday, November 8, 2019

JavaScript inline event handlers, event propagation, event bubbling and capturing, the Event object, and commonly used events in JS - we cover all of these topics in this tutorial.

javascript beginners

Filter Google search results with JavaScript

Friday, November 8, 2019

The ability to use JavaScript right in the browser, via the devtools console, opens up a world of possibilites, and a number of ways to practice using JavaScript. In this tutorial, we'll use JS to filter some search results in the Google search engine.

javascript beginners

Useful JavaScript snippets

Sunday, November 3, 2019

This article lists a number of various snippets, tips, and tricks in JavaScript. This is an open-ended list of some cool ideas in JavaScript.

javascript beginners

The Anatomy of a JavaScript function, part 5

Sunday, October 20, 2019

There are well over a dozen ways to define a function in JavaScript. In this fifth article of the Anatomy of JavaScript functions article series, we go in depth, covering all the ways to define a function in JS.

javascript beginners

The Anatomy of a JavaScript function, part 4

Sunday, October 20, 2019

How to use the function arguments and how are they related to the ES6 speread operator? This is the topic in this fourth article in the article series titled: the Anatomy of JavaScript functions.

javascript beginners

The Anatomy of a JavaScript function, part 3

Saturday, October 19, 2019

What are the differences between ES5 and ES6 functions? We answer this question in this article, third in the series of articles on the Anatomy of JavaScript functions.

javascript beginners

The Anatomy of a JavaScript function, part 2

Friday, October 18, 2019

How to generalize functions in JavaScript? Learn all about it in this second part of the Anatomy of JavaScript functions series of tutorials.

javascript angular beginners

Should I first learn vanilla JavaScript or Angular?

Tuesday, October 8, 2019

It's hard to choose what to learn in web development when there are so many options: should I learn vanilla JS or a framework like Angular? Find the answer in this article.

javascript beginners

Learning JavaScript basics by coding tiny apps

Sunday, September 8, 2019

When you're learning to code, it's always a good idea to try to build apps on your own. These apps don't have to be big; actually, as a beginner, it's better if apps are tiny. In this tutorial, we'll see how to learn JS by building a simple game of choice.

javascript beginners

10 Reasons to Choose JavaScript As Your First Coding Language

Monday, March 18, 2019

If you're planning to start learning a coding language, you can't go wrong with JavaScript. In this article we bring you 10 reasons why choose JavaScript as your first programming language.

javascript beginners

The anatomy of a JavaScript function, part 1

Monday, December 3, 2018

This tutorial compares JS functions to simple machines. We go step by step, building a JS function from scratch. We follow all the technical jargon with in-depth explanations and diagrams. By the end of the article, you should have a solid understanding of how JS functions work. Additionally, this is only the first in a series of several articles about the inner workings of JS functions.

html css javascript beginners

Table border css

Friday, October 19, 2018

In this quick tip tutorial, we see how easy it is to add a border to a table HTML element using CSS, in all the different ways.

Feel free to check out my work here: