title: what is the difference between regex vs split(at least in my case)?
body: <pre><code>\\ regex command
  console.log(str.match(/\n/).length);
  
  \\split() method
  console.log(str.split("\n").length - 1);
  </code></pre>
  
  <p>I will like to know why the regex code does not match as compared with the split() method. A brief background of my coding exercise: I am tasked to find the number of newlines in the string variable <code>str</code>. </p>