Skip to content

@kriskowal /grawlix.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.