I am trying to make a hangman game. So I have a function that takes the word and makes a new array of the underscore dashes. I have that working perfectly but now I am trying to add the functionality of have spacing so multiply words. But now it adds random spaces instead.
Any Help?
function dash(word) {
var dash = [];
for (var i = word.length - 1; i >= 0; i--) {
if (word[i] == " ") {
dash.push(" ");
} else {
dash.push("_");
}
}
return dash;
}