title: Jquery alternate sweet alert
body: <p>I want to run the program so that if the result returned is str4 or str2, the sweet alert will throw up an "error" instead of a "success" icon but I have no idea how.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>$( document ).ready(function() {
  
     $( "#w2" ).click(function() {
      swal({
          title: result(),
          icon: "success",
          button: "OK",
      });
     });
  
  
     function result() {
  
      var str = $("#w1").val().toLowerCase();
      var str2 = "This is not a cafe";
      var str3 = "This cafe does have a plug source";
      var str4 = "This cafe does not have a plug source";
  
      if (str== "cafe express" || str=="cafeexpress") {
          return str3;
      } else if ( str=="jungle cafe" || str=="junglecafe") {
          return str4;
      } else {
          return str2;
      }
  
     }
  
  });
  </code></pre>