Skip to content

Commit

Permalink
Put no-repeat guard on count. Make 10 random words div.
Browse files Browse the repository at this point in the history
  • Loading branch information
atom-box committed Sep 7, 2021
1 parent 8472339 commit 6128443
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions helpers/quilt/wordChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down

0 comments on commit 6128443

Please sign in to comment.