woomy-v2/bot/util/prototypes.js

15 lines
476 B
JavaScript
Raw Normal View History

2020-10-20 05:47:05 +00:00
// 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;
};