SIGN IN SIGN UP

Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.

34083 0 0 JavaScript
2021-12-04 11:01:58 +05:30
/**
* @function lower
* @description Will convert the entire string to lowercase letters.
* @param {String} str - The input string
* @returns {String} Lowercase string
2021-12-04 11:01:58 +05:30
* @example lower("HELLO") => hello
* @example lower("He_llo") => he_llo
*/
const lower = (str) => {
if (typeof str !== 'string') {
throw new TypeError('Invalid Input Type')
}
return str.replace(
/[A-Z]/g, (char) => String.fromCharCode(char.charCodeAt() + 32)
)
2021-12-04 11:01:58 +05:30
}
export default lower