So basically, I made an empty array with JS, which is filled in dynamically based on user choice. Now, I would like a button to appear based on weather or not a value is stored inside the array. And I can't seem to do that, even though a required value is inside the array. Both array and button creation are the part of the same script, if such information makes difference. My code is something like this:
array = [];
//somewhere along the way it get's filled up...
//...
if (array.indexOf("anItem") == true){
var btn = document.createElement('button');
btn.innerHTML = "Text";
btn.setAttribute('id', 'button2');
paragra.appendChild(btn);
}
What am I doing wrong and is there hope for me?