Edit in JSFiddle

document.querySelector('button').addEventListener('click', () => {
  swal(
    'Oops...',
    'Something went wrong!',
    'error'
  )
})
<button>Try me!</button>