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;
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;
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();
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);
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);
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);
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);
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('');
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);
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() : '');