Tag: exercises

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