# Newest Articles

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.