Button is not working when clicked

Can someone please help me out with this code, when I click the button it is not working and I don’t know why. I am also very new to coding, anything helps:

image

Hi @fem115 welcome to the community!

Can you please post a link to your Repl so others in the community can test your code and offer some suggestions?

Instead of using an event listener in JS, you can write <button onclick=“buttonGenerate()”>Click</button>

Your button is stored in a variable called buttonGenerate, your callback function to handle the click event for this button is called buttonGenerate… These two variables have the same name, this is probably causing the issue.

Also, on line 34, unless you’re actually using HTML, it’s better to use textContent than innerHTML.