title: if string contains else if it doesn't contain - Javascript
body: <p>I am simply trying to check whether a string, in this case the document title, contains a certain word, and if it does display "str1" if it doesn't contain the certain word display "str2"</p>
  
  <pre><code>var str1 = document.title.replace(/NEW - Business Name/i, '');
  var str2 = document.title.replace(/ - Business Name/i, '');
  if(document.title.indexOf("Sale") == 1){
  document.write(str1);}  else
  if(document.title.indexOf("Sale") != 1){
  document.write(str2);}
  </code></pre>