how to write a function that checks for correct guesses?

I recently coded the hangman game in javascript but without functions. And now that I am trying to write it with functions I can not manage to write the “update the Game State” Function that checks for correct guesses. Can anyone please help?.