Skip to content

Instantly share code, notes, and snippets.

@Last-Order
Created September 25, 2016 23:15
Show Gist options
  • Save Last-Order/8e489266b451c9539254c398342ce5cc to your computer and use it in GitHub Desktop.
Save Last-Order/8e489266b451c9539254c398342ce5cc to your computer and use it in GitHub Desktop.
"use strict"
var dict = {};
var appendToDict = (char) => {
if (dict[char]) dict[char]++
else dict[char] = 1;
}
var convert = (string) => {
string.toLowerCase().split('').map(appendToDict);
for (key of Object.keys(dict)) {
string = string.replace(new RegExp(key, 'ig'), dict[key] % 2 == 0 ? '\$' : '#');
}
return string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment