Why I cant display elements that I push into an array, into an html div. Im just trying to print the word hello 3 times, but it does not work. When I print the array into the console the array does show the 3 Hello's.
$(function() {
var $buttonsArray = [];
var $buttondiv = $('#btndiv');
for (var i = 0; i < 3; i++) {
var $button = "hello";
$buttonsArray.push($button);
}
for (var j = 0; j < $buttonsArray.length; j++) {
$buttondiv.append($buttonsArray[j]);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="btndiv"></div>