woomy-v2/bot/util/prototypes.js
2020-10-20 16:47:05 +11:00

15 lines
No EOL
476 B
JavaScript

// YEAH IM EXTENDING PROTOTYPES FUCK YOU
String.prototype.toProperCase = function () {
return this.replace(/([^\W_]+[^\s-]*) */g, function (txt) {return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
};
Array.prototype.random = function () {
return this[Math.floor(Math.random() * this.length)];
};
Array.prototype.remove = function (element) {
const index = this.indexOf(element);
if (index !== -1) this.splice(index, 1);
return this;
};