Promises from scratch

by kpulkit29

HTML

<div id="editor">
<div class="1">
   tab 1
</div>
<div class="2">
   tab 2
</div>
<div class="3">
   tab 3
</div>
</div>

CSS

#editor {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  overflow-y: auto;
}

#editor > div {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  margin: 10px;
}

JavaScript

/* document.getElementById("editor").addEventListener("input", function(e) {
    console.log(e.target.textContent);
}, false);

function beautify() {
    const text = JSON.parse(document.getElementById("editor").innerText);
    document.getElementsByClassName("output")[0].value  = JSON.stringify(text, null, 7);
    
}

const observer = new IntersectionObserver(entries => {
  entries.forEach(entry => {
  console.log(entry);
    const intersecting = entry.isIntersecting
    entry.isIntersecting && (entry.target.style.backgroundColor = "green")
  })
}, {
root: document.getElementById("editor"),
  threshold: 0.7
})

observer.observe(document.getElementsByClassName("3")[0]); */
function at() {
	throw "sdsd";
}

let ans;
try {
	ans = at();
} catch(err) {
	ans = err;
  console.log(ans, "here");
}