From 61284435b901b4b2bc0a4002c562fc84cc4574d9 Mon Sep 17 00:00:00 2001 From: atom-box Date: Tue, 7 Sep 2021 09:47:00 -0500 Subject: [PATCH] Put no-repeat guard on count. Make 10 random words div. --- helpers/quilt/wordChecker.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helpers/quilt/wordChecker.js b/helpers/quilt/wordChecker.js index f783a4e..074d088 100644 --- a/helpers/quilt/wordChecker.js +++ b/helpers/quilt/wordChecker.js @@ -5,7 +5,13 @@ wordChecker.date = () => { return new Date(); }; +// A guard so that repeatedly pushing the button does not append redundant divs let countWasClicked = false; +/** + * + * @param {An array} words + * @returns number of items in the array + */ wordChecker.count = (words) => { if (countWasClicked){return} countWasClicked = true; @@ -15,6 +21,12 @@ wordChecker.count = (words) => { existing.appendChild(newChild); } +/** + * + * @param {An array of words} words + * @param {How many words to return} n + * Returns n randomly chosen words, as a string + */ wordChecker.random = (words, n) => { console.log(new Date()); let existing = document.getElementById('word-checker-random');