Faced such a problem: you need to insert li
tags in the <ul>
tag in an amount equal to the number of elements in the array.
var player = ["10","9"]; //это как пример while (i <= player.length){ cardsPlayer.innerHTML += '<li data-value=' + '"' + player[i] + playerSymbol[i] + '"' + '><p><span></span>'+ playerSymbol[i] + '</p></li>'; i++; }
But instead of 2 elements, 3.2 is displayed normally, and the third Undefined
.
Where did I make a mistake? yet true, the array is strictly specified.