T19 - js - addElement
Fri Nov 12 2021 08:02:33 GMT+0000 (UTC)
Saved by
@patriciamolnar
#javascript
const addElement = () => {
const typeNum = Math.round(Math.random()); //returns 0 or 1;
const newEle = document.createElement('div');
if(typeNum === 0) {
configureWideElement(newEle);
} else {
configureTallElement(newEle);
}
newEle.style.left = coordinates.x + 'px';
newEle.style.top = coordinates.y + 'px';
header.appendChild(newEle);
}
content_copyCOPY
Comments