[Solved] Variable not working (no idea why) javascript


you shouldn’t redefine your underscore variable in your for loop.

ie, dont do

for (i = 0; i < word.length; i++)   {
        var underscore = underscore + "_ ";
    }

instead

for (i = 0; i < word.length; i++)   {
        underscore += "_ ";
    }

thats just the most glaring thing i noticed..

in the future it helps to accompany your question with a jsfiddle example. you can get quicker and more accurate responses if we can quickly repro what you’re seeing.

1

solved Variable not working (no idea why) javascript