dimanche 10 février 2019

Replacing spaces with blanks in an array

I'm building a hangman game that revolves around bands. Some of the bands have spaces and when the underscores are pushed the spaces are read as blanks to be guessed. In my for loop, when you I am pushing the underscores to the guessingWord array I am trying to add a conditional that checks to see if the current letter is a $; if it is I want to push a space, otherwise push an underscore. I need an if/else statement I believe but nothing I have come up with is working.

for (var i = 0; i < bands[currentWordIndex].length; i++) { 
    guessingWord.push("_");

}

Aucun commentaire:

Enregistrer un commentaire