We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b7d7d1 commit 5bc9df9Copy full SHA for 5bc9df9
implementations/toUpperCase.js
@@ -10,11 +10,15 @@
10
We're checking this condition to implement this function.
11
*/
12
String.prototype.toUpperCase = function myToUpperCase() {
13
- return this.split('').reduce((acc, character) => {
+ let upperCaseString = '';
14
+ for (let i = 0; i < this.length; i += 1) {
15
+ const character = this[i];
16
const charCode = character.charCodeAt();
17
if (charCode >= 97 && charCode <= 122) {
- return acc + String.fromCharCode(charCode - 32);
18
+ upperCaseString += String.fromCharCode(charCode - 32);
19
+ } else {
20
+ upperCaseString += character;
21
}
- return acc + character;
- }, '');
22
+ }
23
+ return upperCaseString;
24
};
0 commit comments