Skip to content

Commit d390969

Browse files
authored
Probably the worst method ever used in the history of JavaScript
1 parent 5f04297 commit d390969

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

p5.input.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ window.aKeyPressed = false;
66
String.prototype.replaceAll = function (stringToFind, stringToReplace) {
77
if (stringToFind === stringToReplace) return this;
88
var temp = this;
9-
var index = temp.indexOf(stringToFind);
10-
while (index != -1) {
11-
temp = temp.replace(stringToFind, stringToReplace);
12-
index = temp.indexOf(stringToFind);
13-
}
9+
temp = (((stringToFind.length < 1) && temp.includes(stringToFind)) ? (temp.split(stringToFind).join(stringToReplace)) : (temp))
1410
return temp;
1511
};
1612

0 commit comments

Comments
 (0)