0

I cannot figure out what is wrong here.

for ( var i = 0; i< choices.length; i++) {
        element = document.getElementById("choice" + i);
        element.innerHTMl = choices[i];
        Guess ("btn" + i, choices[i]);
    }
  • Also it should be innerHTML, not innerHTMl (last letter is lowercase in your case). – Bobo Dec 09 '16 at 22:24

1 Answers1

0

Its innerHTML and you need to make sure the element exists.

for ( var i = 0; i< choices.length; i++) {
    element = document.getElementById("choice" + i);
    if( element ) {
        element.innerHTMl = choices[i];
        Guess ("btn" + i, choices[i]);
    } 
}
Blake A. Nichols
  • 870
  • 1
  • 6
  • 11