## Javascript: Count the occurrences of each word in a string

June 23, 2022 A Goodman

The example below shows you how to count the occurrences of each word in a given sentence in Javascript. The result will be an object where each key is a word and the value is the…

## Javascript: 3 Ways to Calculate the Sum of an Array

June 23, 2022 A Goodman

This practical, succinct article walks you through three examples that use three different approaches to find the sum of all elements of a given array in Javascript (suppose this array only contains numbers). Without any further…

## Javascript Object: Find the Key(s) of a given Value

June 23, 2022 A Goodman

This practical, concise article shows you a couple of different ways to get the key if know its value in a Javascript object. Without any further ado, let’s write some code. Caveat: It is possible that…

## Javascript: 2 Ways to Find Min/Max Property of an Object

June 23, 2022 A Goodman

This short and straight-to-the-point shows you two different ways to get the minimum and maximum properties of a Javascript object (assuming this object has two or more properties with all values being numeric). The Modern Way…

## Javascript: 3 Ways to Find Min/Max Number in an Array

June 23, 2022 A Goodman

This article walks you through a couple of different ways to find the minimum and maximum numbers in a Javascript array. Knowing more than one solution to solve a problem can help you understand Javascript more…

## Javascript: How to Reverse an Integer

June 23, 2022 The Plumber

In Javascript, you can reverse a given integer (e.g. turn 123 to 321, -456 to -654, 1200 to 21) by performing the following steps: Convert the integer to a string Reverse that string Turn the reversed…

## 3 Ways to Reverse a Given String in Javascript

June 22, 2022 The Plumber

The three examples below show you three different approaches to reverse a given string in Javascript. Without any further ado, let’s get started. Using Array.reverse() method The code with explanations: Console output: You can shorten the…

## Vanilla Javascript: Detect a click outside an HTML element

June 13, 2022 Pennywise

With Javascript, you can easily detect if the user clicks somewhere outside a given HTML element. For example, the code snippet below shows you how to catch a click outside an element with the id of…

## Javascript: Convert UTC time to local time and vice versa

March 19, 2022 A Goodman

This concise article shows you how to convert UTC date-time into local date-time and turn local date-time into UTC date-time in Javascript. UTC Time to Local Time Using Date.toLocaleString() method Example: Output: Note that the output…

## Calculate Variance and Standard Deviation in Javascript

November 15, 2021 The Plumber

This short article shows you how to calculate the variance and standard deviation of a given array of numbers. You will see the code in vanilla Javascript and TypeScript. Javascript Output: TypeScript If you use TypeScript…

## Javascript: Capitalize the First Letter of Each Word (Title Case)

November 9, 2021 A Goodman

This short article shows you how to capitalize the first letter of each word in a string. hypothetical inputs and expected outputs: we will just capitalize the first letter of a word and keep the rest…

## Javascript: Looping through Keys/Values of an Object

September 6, 2021 A Goodman

The examples below show you how to loop through keys/values of a given object in Javascript. Example 1: Using Object.entries() The entries() method returns an array of a given object. It’s supported in all modern browsers…