javascript - Puzzling behavior from IF ( ) statement -
i'm total n00b javascript , expect appallingly obvious cannot understand why if ( ) statement not producing correct results.
no matter how many characters input function returns 'yes' console whether 'word' < or > 2. if (ha!) can shed light on it's appreciated. code below:
var word = document.getelementbyid('wordchoice').value; function flipchk () { if (word.length < 2) { console.log('yes'); } else { console.log('no'); } }
see implemented code here: http://supsean.com/supsean/flipr/flipr.html
have tried debugging code , seeing value of word
when click button?
i'm guessing part of problem you're assigning value word
when page loads not reading again when user clicks button.
Comments
Post a Comment