public
Created

  • Download Gist
grawlix.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 
var GRAWLIX = "@#$%&*";
String.prototype.grawlix = function () {
return this.split(" ").map(function (word) {
var dictionary = {};
var previous;
return Array.prototype.map.call(word, function (char) {
if (!/\w/.test(char))
return char;
var code = char.charCodeAt();
if (!dictionary[code]) {
dictionary[code] = GRAWLIX[code % GRAWLIX.length];
if (previous == dictionary[code])
dictionary[code] = GRAWLIX[(code + 1) % GRAWLIX.length];
previous = dictionary[code];
}
return dictionary[code];
}).join("");
}).join(" ");
};
 
console.log("fuck".grawlix());
console.log("ass".grawlix());
console.log("poo darn!!".grawlix());

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.