title: Why isnt this string parsing function working?
body: <p>I created a function to delete the spaces out of a string and return the strings length with out spaces, however the function is deleting more then just the spaces. Also is there a better way of accomplishing this, assuming this function can be fixed.</p>
  
  <pre><code>let string="This string is going to lose characters";
  
  function charLength(str){
      let strArray=str.split("");
      let output="";
  
      for(let i=0; i &lt; strArray.length; i++){
          if(strArray[i]===" "){
              strArray.splice(strArray[i],1);
          }
          else{
              output+=strArray[i];
          }
      }
      return output.length // + " " output, if I were to add this you would see its deleting characters
  }
  
  charLength(string);//returns "27 Thistringsoingooseharacters", not "33 Thisstringisgoingtolosecharacters"
  </code></pre>