How to find previous element in JavaScript

DOM
By Jad Joubran · 
Last updated Mar 11, 2018
<div id="box1"></div>
<div id="box2"></div>
const box2 = document.querySelector("#box2");
const box1 = box2.previousElementSibling;