title: javascript - return string before one of these characters
body: <p>I want to return a string before one of these elements. if the string is still more than 80 characters, I return them until 80 characters.</p>
  
  <p><code>"Hello! my name is Marcel. I am 30 years old -"</code> => <code>"Hello!"</code></p>
  
  <p><code>"Hello, my name is Marcel. I am 30 years old,"</code> => <code>"Hello, my name is Marcel."</code></p>
  
  <p><code>"Hello my name is Marcel &lt;br/&gt; I am 30 years old -"</code> => <code>"Hello my name is Marcel"</code></p>
  
  <p>Here si what I tried, and I feel like there must me something much more simple:</p>
  
  <pre><code> getStrWithMinOfElements(str){
                var arr=[str.indexOf('.'), str.indexOf('!'), str.indexOf('&lt;br'), str.indexOf('-')];
                var index = arr.indexOf(-1);
                if (index &gt; -1) {
                  arr.splice(index, 1);
                }
                index = arr.indexOf(-1);
                if (index &gt; -1) {
                  arr.splice(index, 1);
                }
                index = arr.indexOf(-1);
                if (index &gt; -1) {
                  arr.splice(index, 1);
                }
  
                var min = Math.min(...arr);
                if(min&lt;8 || min&gt;80) return str.substring(0,80);
                return str.substring(0,min);
              }
  </code></pre>