Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is all that is in the p5.js file const words = wordList; const guesses = []; const word = ; Javascript Here is this

This is all that is in the p5.js file

const words = wordList;

const guesses = [];

const word = "";

Javascript

Here is this HTML file I'm working with:

P5

Word Guess

Word:

Guess>Start>

Letters Guessed

I already have both p5.js and p5-word.js

Here is the question for what I must add to p5.js:

At the top of my p5.js I have these variables initialized:

const words = wordsList; //refers to words array from p5-words.js

const guesses = []; //initailized to empty array

const word = ""; //initialized to empty string

E. handleGuessButtonClick() function

This function is called when the Guess button is clicked, and will retrieve text from the input box. The function should do nothing if the game has not yet been started (Hint: Check if word length > 0).

Use addEventListener() to connect this function to the appropriate button to handle the click event.

Letter entry rules are:

  • Remove any whitespace
  • Only take the first character
  • All characters are converted to uppercase
  • Already guessed letters are ignored (Hint: Investigate array indexOf() method)

After each new guessed letter:

  • Update the listing of guessed letters
  • Update the word with underscores display

After any new guessed letter:

  • Clear the input box

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago