X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lmno.js;h=71ccc58165298b3e313fa7f60e0422fb19e3b7b6;hb=325a886a5d84c42c67e7075c734b74619d383ea2;hp=de95aa417a390caa65d26579a54d7e61a3106978;hpb=1b8674fabbdfab627f12727cdc3616a233cd767a;p=lmno-server diff --git a/lmno.js b/lmno.js index de95aa4..71ccc58 100644 --- a/lmno.js +++ b/lmno.js @@ -101,7 +101,11 @@ class LMNO { } generate_id() { - return Array(4).fill(null).map(() => LMNO.letters.charAt(Math.floor(Math.random() * LMNO.letters.length))).join(''); + /* Note: The copy from Array(4) to [...Array(4)] is necessary so + * that map() will actually work, (which it doesn't on an array + * from Array(N) which is in this strange state of having "empty" + * items rather than "undefined" as we get after [...Array(4)] */ + return [...Array(4)].map(() => LMNO.letters.charAt(Math.floor(Math.random() * LMNO.letters.length))).join(''); } create_game(engine_name) {