This is quite a simple function, but I just wanted some opinions on it, like is this the correct way to run a function and check if an element exists or not?const button = document.querySelector('.js-brand-video--thumbnail')const iframe = document.querySelector('.js-brand-video--iframe')function playVideo () {  if (button) {    button.classList.add('video-poster--hidden')    iframe.src = iframe.getAttribute('data-src')  }}if (button)  button.addEventListener('click', playVideo, false)
iframe play & thumbnail function
javascript;beginner;dom;video