I have written this javascript code to add images each after a delay of 3 seconds but this code is not working kindly help.
function start() {
while(true) {
setTimeout(addObstracles(), 3000)
}
}
function addObstracle() {
var element = document.createElement('img');
element.id = 'obs';
element.className = 'obstracleAnimation';
element.src = 'enemy.png';
element.style.position = 'absolute';
element.style.top = '0px';
element.style.left = '100%';
element.style.width = '150px';
element.style.height = '100px';
document.body.appendChild(element);
}