Newest Articles

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.

Feel free to check out my work here: