In this Article we will go through how to check if a string contains upper 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 containsUpperCase = str => str !== str.toLowerCase();
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 a string is a hexadecimal color 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 isHexColor = color => /^#([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(color);
In this Article we will go through how to check if a string contains whitespace 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 containsWhitespace = str => str => /\s/.test(str);
In this Article we will go through how to calculate the midpoint between two points 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 midpoint = (p1, p2) => [(p1.x + p2.x) / 2, (p1.y + p2.y) / 2];
In this Article we will go through how to check if a string is a hexadecimal number 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 isHexadecimal = str => /^[A-F0-9]+$/i.test(str);
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 is upper case 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 isUpperCase = str => str === str.toUpperCase();
In this Article we will go through how to check if a string is lower case 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 isLowerCase = str => str === str.toLowerCase();
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;