I have a string that I'd like to get all possible replace
-ment combinations on using the following substitutions:
var equiv = {
"a": "4",
"b": "8",
"e": "3",
"i": "1",
"l": "1",
"o": "0",
"t": "7"
}
I would like to define a String.prototype
function, something like:
String.prototype.l33tCombonations = function()
{
var toReturn = [];
for (var i in equiv)
{
// this.???
// toReturn.push(this???)
}
return toReturn;
}
So I could feed in something like "tomato".l33tCombinations()
and get back:
["tomato", "t0mato", "t0mat0", "tomat0", "toma7o", "t0ma7o", "t0m470", ...].
Order is not important. Thoughts?