Does this line need it's own function, or no?

Would this line be added into here.

document.body.style.backgroundColor = "green";


(function iife() {
  "use strict";

  function show(el) {
    el.classList.remove("hide");
  }

  function hide(el) {
    el.classList.add("hide");
  }

  function coverClickHandler(evt) {
    const cover = evt.currentTarget;
    const thewrap = cover.parentNode.querySelector(".container");
    document.body.style.backgroundColor = "green";
    hide(cover);
    show(thewrap);
  }
  const cover = document.querySelector(".jacketa");
  cover.addEventListener("click", coverClickHandler);
}());

Or would it be better to keep them separate?

(function iife() {
  "use strict";

  function backClickHandler(evt) {
    document.body.style.backgroundColor = "green";

  }
  const back = document.querySelector(".jacketa");
  back.addEventListener("click", backClickHandler);
}());

As written, they are equivalent statements, and so there’s no difference.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.