Skip to content

Commit 9453800

Browse files
author
Ravindra Chhetri
committed
PATCH - removed split function
1 parent c7483d8 commit 9453800

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

implementations/toLowerCase.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
And characters from a-z have ASCII code from 97-122.
1010
We're checking this condition to implement this function
1111
*/
12-
String.prototype.toLowerCase = function myToLowerCase() {
13-
return this.split('').reduce((acc, character) => {
12+
String.prototype.toLowerCase = function myToUpperCase() {
13+
let lowerCaseString = '';
14+
for (let i = 0; i < this.length; i += 1) {
15+
const character = this[i];
1416
const charCode = character.charCodeAt();
1517
if (charCode >= 65 && charCode <= 90) {
16-
return acc + String.fromCharCode(charCode + 32);
18+
lowerCaseString += String.fromCharCode(charCode + 32);
19+
} else {
20+
lowerCaseString += character;
1721
}
18-
return acc + character;
19-
}, '');
22+
}
23+
return lowerCaseString;
2024
};

0 commit comments

Comments
 (0)