Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript This is the HTML file I'm working with: P5 Word Guess Word: Guess > Start > Letters Guessed At the top of my p5.js

JavaScript

This is the HTML file I'm working with:

P5

Word Guess

Word:

>>

Letters Guessed

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

function handleStartRestartButtonClick() { var elem = document.getElementById("startButton"); //Get element in var "elem" elem.innerHTML = 'Restart'; //Change inner text to "Restart" var str2 = "_"; //new string = "_" word = str2; //make word = _ guesses.splice(0, guesses.length); //Empty the "guesses" array. }

This is question I need answered:

H. displayWordUnderscores() function

This function will update the word span with either underscores for unguessed word letters, or the guess letter. Underscores or letters must be separated by a space.

Additional notes:

Make a new array that has the same amount of underscores as the word has letters- this is what you are gonna want to display. Then use a for loop to cross-check the contents of your guesses array with your word and if they match, then replace the index value or your new array with the same index value of where that letter is in your word.

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago