Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const wordHolder = document.getElementsByClassName('wordHolder')[0];
- const words = ['c', 'a', 't'];
- const hold = document.createElement('ul');
- wordHolder.appendChild(hold);
- words.forEach(() => {
- const guess = document.createElement('li');
- hold.appendChild(guess);
- guess.innerHTML = '-';
- });
- // const $alphabetLi = $('.alphabetLi');
- // const $guess = $('.guess');
- function clickEvent() {
- cells.forEach((cell) => {
- if ($(cell).hasClass('purple')) {
- $(cell).on('click', (e) => {
- const text = e.target.innerHTML;
- wordArray.push(text);
- $(e.target).removeClass('purple');
- e.target.innerHTML = '';
- placeRandomLetter();
- $(cell).off('click');
- console.log('the word array is: ' + wordArray);
- $wordInPlay.text(wordArray);
- // score += 1;
- // $score.text(score);
- // console.log('testing' + text);
- });
- }
- });
- }
- words.forEach((word) => {
- $(word).on('click', (e) => {
- const text = e.target.innerHTML;
- const indexInWord = words.indexOf(text);
- console.log('clicking');
- if (indexInWord !== -1) {
- guess.eq(indexInWord).text(text);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement