Tag: Exercises

vue exercises beginners

Vue.js tips and tricks

Thursday, February 11, 2021

Looking for Vue.js tips and tricks? This ever-growing list of tips and tricks in using Vue.js comes from the day-to-day work as a Vue.js developer. Like some other blog posts on this site, it doesn't have too much content now, but I'll keep adding stuff as I stumble upon it in my day-to-day work.

vue exercises beginners

Build the smallest possible Vue app

Wednesday, February 10, 2021

In this gentle introduction to Vue.js we'll learn about the basic ins and outs of this modern JS framework.

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.

Feel free to check out my work here: