This is part of the code; the function works correctly, however having trouble coding the comparison statement in order to display correct letters on screen
function play() {
let index = Math.floor(Math.random()* words.length)
console.log(words[index])
for(let i = 0; i < words[index].length; i++){
console.log(words[0][i])
let div = document.createElement('div')
div.innerHTML=' - '//words[0][i]
document.querySelector('.hold-words').append(div)
//This is the section I know is incorrect looking for guidelines
if (words[index] === ' - '){
words.innerHTML === ' - '
wordSpace = '- '
}
words.push('- ')
}const buttons = document.querySelectorAll('button')
buttons.forEach(button => button.addEventListener('click', e => {
console.log(e.target.innerHTML)
}))