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); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter