lundi 30 mars 2020

Adding a third condition in else if statement

I have an alert message showing under certain conditions. I currently have two conditions and the alert message is working the way I want. I am attempting to add a third condition but when doing so it does not appear at all even for the two conditions before it.

My logic breakdown that I am trying to create with an if else statement.

If isDismissed is true do not show alert. If cookie isDimissed does not exist, display alert for title "Test" or "New Article"

$(window).on("load", function(e) {
  $('.preloader').fadeOut('slow');

  if (document.cookie.includes("isDismissed=true")) {
    document.body.classList.add("alert.container");
  } else if ("@pageTitle".indexOf("Test") !== -1) {
    document.body.classList.add("show-alert");
  } else { ("@pageTitle".indexOf("New Article") !== -1) {
    document.body.classList.add("show-alert");
});

Aucun commentaire:

Enregistrer un commentaire