Tag: exercises

11 Feb 2021
Vue.js tips and tricks
Looking for Vue.js tips and tricks? This ever-growing list of tips and tricks in using Vue.js com...
10 Feb 2021
Build the smallest possible Vue app
In this gentle introduction to Vue.js we'll learn about the basic ins and outs of this modern JS ...
27 Jan 2021
Hoisting differences related to keywords var, let and const in JS
We all know that the var keyword should not be used in our code, and that we should mostly use le...
27 Jan 2021
Find the key code for a keydown or keyup event in JavaScript
Key up and key down events in JS return a bunch of information in the Event object. This informat...
26 Jan 2021
Using cookies in JavaScript
Cookies are one of the oldest ways of saving text-based data on the web. The data that gets saved...
22 Jan 2021
Convert an object to array in JS
Converting an object to an array is pretty easy in JavaScript. All we have to do is use Object.ke...
21 Jan 2021
Get an object's length in JavaScript
To get the length of an object in JS, we use Object.keys() to get an array of our object's own pr...
18 Jan 2021
Build a multi-dimensional array in JavaScript
How to build matrices in JS? Also known as multi-dimensional arrays, these are just arrays of arr...
18 Jan 2021
Convert kebab case to camel case in JavaScript
It's the combination of String.prototype.match(), RegExp, and String.prototype.replace() that giv...
18 Jan 2021
Capitalize the first letter of a string in JavaScript
The trick is to separate the string into the first letter and the rest of the string using charAt...
17 Jan 2021
Insert CSS styles with JavaScript
Appending a style tag to the head tag of an HTML document requires some simple DOM manipulation. ...
17 Jan 2021
Compute the factorial of a number with JavaScript
Calculating a factorial is very easy, but many JS implementations online make this problem unnece...
16 Jan 2021
Calculate the Fibonacci sequence in JS
Fibonacci sequence in JS should not be hard to build. In this article, we show step-by-step, how ...
15 Jan 2021
Count the number of times a substring appears in a string in JavaScript
Have you ever tried to see how many times a letter or a word appears in a string? Or how many tim...
14 Jan 2021
Convert an array of numbers to an array of ordinal numbers in JS
To format an array of numbers as ordinal numbers, we need to properly add the suffixes -st, -nd, ...
13 Jan 2021
Format a number as currency in JS
Formatting a number as currency in JS is easy. We can use Intl.NumberFormat(), and style it as cu...
12 Jan 2021
Format a number with comma as a thousands separator in JS
In JS, we can add a comma as thousands separator using the toLocaleString() method, or using Intl...
11 Jan 2021
Generate a random sub-array from a larger array
To get a random, three-member sub-array from an array of items, we need to use the splice, Math.r...
10 Jan 2021
Add random CSS classes to a paragraph in JavaScript
We have a web page with a script tag. That script tag holds an array of various Bootstrap 4 CSS c...
09 Jan 2021
Generate a random password with JavaScript
We can easily whip up our own password generator in vanilla JS. This tutorial shows you how to do...
08 Jan 2021
Randomize the order of members in a JavaScript array
Randomly reordering members of a JavaScript array might seem an easy task, but it can also be dif...
07 Jan 2021
Get a number randomly from a range of numbers in JS
Math.random() gives us a range between 0 (inclusive) and 1 (exclusive). But how do we use this me...
07 Jan 2021
Randomly return a true or false from a JavaScript function
Using the conditional (ternary) operator, we are able to easily return, at random, either a boole...
06 Jan 2021
Pick a random member from a JavaScript array
Multiply the length of array with the call to Math object's random method, then floor the result....
05 Jan 2021
Emulate a six-sided dice
Use Math.random() static method to emulate a pair of dice in JavaScript, and keep in mind these s...