Skip to content
Advertisement

How to make list have correct number of variables inside them depending on length of one variable

I am pretty new to coding and am working on writing hangman to enhance my skills

I want the code to be able to detect how long a word is and then put that length into the correct number of variables in a array. I don’t really know how to describe it, but for example if the word was 3 letters long the array would have letter one, letter two and letter three stored in it. Something like word[0-2].

JavaScript

Advertisement

Answer

You could try this

JavaScript

Here correctLetters will have all the letters exactly once from the input that the user have entered

Advertisement