diff --git a/random-substitution-cipher/index.js b/random-substitution-cipher/index.js new file mode 100644 index 0000000..6850b42 --- /dev/null +++ b/random-substitution-cipher/index.js @@ -0,0 +1,7 @@ +// https://www.codewars.com/kata/random-substitution-cipher/javascript + +function randomSub() { + const alph = 'abcdefghijklmnopqrstuvwxyz'.split``; + const rnd = alph.slice().sort(() => Math.random()-0.5); + return alph.reduce((res, k, i) => (res[k] = rnd[i], res), {}); +} \ No newline at end of file