Preview:
export const getElement = (selection) => {
  const element = document.querySelector(selection);
  if (element) {
    return element;
  }
  throw new Error(
    `Please check "${selection}" selector, no such element exists`
  );
}


export const getAllElements = (elements) => {
    const allelements = document.querySelectorAll(elements);
    if(allelements){
      return allelements
    }
    throw new Error(`These ${elements} cannot be found`)
}
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