How to make conditional click action on button?

I want to handle conditional click action with custom javascirpt.
i just want to distinguish browser and handle action by js not only unbounce click action.
how can i do this?

const test = document.querySelector('#unbounce-button');
test.onclick = () => {
  if (
    (navigator.appName == 'Netscape' &&
      navigator.userAgent.toLowerCase().indexOf('trident') != -1) ||
    navigator.userAgent.toLowerCase().indexOf('msie') != -1
  ) {
    // IE : activate custom action and ignore click action from unbounce
  } else {
    // other browser : activate click action from unbounce
  }
};