daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   const wordHolder = document.getElementsByClassName('wordHolder')[0];
  2.   const words = ['c', 'a', 't'];
  3.  
  4.   const hold = document.createElement('ul');
  5.   wordHolder.appendChild(hold);
  6.  
  7.   words.forEach(() => {
  8.     const guess = document.createElement('li');
  9.     hold.appendChild(guess);
  10.     guess.innerHTML = '-';
  11.   });
  12.  
  13.  
  14.  
  15.   // const $alphabetLi = $('.alphabetLi');
  16.   // const $guess = $('.guess');
  17.  
  18.   function clickEvent() {
  19.     cells.forEach((cell) => {
  20.       if ($(cell).hasClass('purple')) {
  21.         $(cell).on('click', (e) => {
  22.           const text = e.target.innerHTML;
  23.           wordArray.push(text);
  24.           $(e.target).removeClass('purple');
  25.           e.target.innerHTML = '';
  26.           placeRandomLetter();
  27.           $(cell).off('click');
  28.           console.log('the word array is: ' + wordArray);
  29.           $wordInPlay.text(wordArray);
  30.           // score += 1;
  31.           // $score.text(score);
  32.  
  33.           // console.log('testing' + text);
  34.         });
  35.       }
  36.     });
  37.   }
  38.   words.forEach((word) => {
  39.  
  40.     $(word).on('click', (e) => {
  41.       const text = e.target.innerHTML;
  42.       const indexInWord = words.indexOf(text);
  43.       console.log('clicking');
  44.       if (indexInWord !== -1) {
  45.         guess.eq(indexInWord).text(text);
  46.       }
  47.     });
  48.   });
RAW Paste Data
Top