2021-12-04 11:01:58 +05:30
|
|
|
/**
|
|
|
|
|
* @function lower
|
|
|
|
|
* @description Will convert the entire string to lowercase letters.
|
2022-02-19 17:38:55 +06:00
|
|
|
* @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')
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 15:29:21 +06:00
|
|
|
return str.replace(
|
|
|
|
|
/[A-Z]/g, (char) => String.fromCharCode(char.charCodeAt() + 32)
|
|
|
|
|
)
|
2021-12-04 11:01:58 +05:30
|
|
|
}
|
|
|
|
|
|
2022-03-28 15:29:21 +06:00
|
|
|
export default lower
|