mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-08 12:35:16 +08:00
merge: reduce upper & lower & add export default (#960)
This commit is contained in:
@ -12,12 +12,9 @@ const lower = (str) => {
|
||||
throw new TypeError('Invalid Input Type')
|
||||
}
|
||||
|
||||
return str
|
||||
.replace(/[A-Z]/g, (_, indexOfUpperChar) => {
|
||||
const asciiCode = str.charCodeAt(indexOfUpperChar)
|
||||
|
||||
return String.fromCharCode(asciiCode + 32)
|
||||
})
|
||||
return str.replace(
|
||||
/[A-Z]/g, (char) => String.fromCharCode(char.charCodeAt() + 32)
|
||||
)
|
||||
}
|
||||
|
||||
export { lower }
|
||||
export default lower
|
||||
|
Reference in New Issue
Block a user