Sep 9, 2021 JavaScript
How to check if a number is odd in JavaScript

In this Article we will go through how to check if a number is odd only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isOdd = number => number % 2 !== 0;

Sep 9, 2021 JavaScript
How to check if a number is positive in JavaScript

In this Article we will go through how to check if a number is positive only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isPositive = number => Math.sign(number) === 1;

Sep 9, 2021 JavaScript
How to check if a string contains lower case characters in JavaScript

In this Article we will go through how to check if a string contains lower case characters only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const containsLowerCase = str => str !== str.toUpperCase();

Sep 9, 2021 JavaScript
How to check if a string contains only ascii characters in JavaScript

In this Article we will go through how to check if a string contains only ascii characters only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isAscii = str => /^[\x00-\x7F]+$/.test(str);

Sep 9, 2021 JavaScript
How to check if a string contains only digits in JavaScript

In this Article we will go through how to check if a string contains only digits only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isNumeric = str => !/[^0-9]/.test(str);

Sep 9, 2021 JavaScript
How to check if a string contains only letters and numbers in JavaScript

In this Article we will go through how to check if a string contains only letters and numbers only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isAlphanumeric = str => /^[0-9A-Z]+$/i.test(str);

Sep 9, 2021 JavaScript
How to check if a string contains only letters in JavaScript

In this Article we will go through how to check if a string contains only letters only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isAlpha = str => /^[A-Z]+$/i.test(str);

Sep 9, 2021 JavaScript
How to check if two strings are anagram in JavaScript

In this Article we will go through how to check if two strings are anagram only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const areAnagram = (str1, str2) => str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');

Sep 9, 2021 JavaScript
How to convert a letter to associate emoji in JavaScript

In this Article we will go through how to convert a letter to associate emoji only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const letterToEmoji = c => String.fromCodePoint(c.toLowerCase().charCodeAt() + 127365);

Sep 9, 2021 JavaScript
How to convert a string to camelcase in JavaScript

In this Article we will go through how to convert a string to camelcase only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const toCamelCase = str => str.trim().replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '');