I was playing a bit more with html to add to my website, and following this question [Dissappear content with html](https://stackoverflow.com/questions/65689709/dissappear-content-with-html/65690613#65690613), I now have a phone number box and my javascript code tells me how many characters are in the inputs box, but also includes the spaces. Is there anyway for my javascript to calculate how many characters there are excluding the the spaces?

```html
<!DOCTYPE html>
<html>
<body>

  <p>Click the button to return the number of characters in the string "Hello World!".</p>
  <input id="id"></input>
  <button onclick="myFunction()">Try it</button>

  <p id="demo"></p>

<script>
function myFunction() {
  var a = document.getElementById("id").value
  var str = a
  var n = str.length;

  if(n==10) {
    document.getElementById("demo").innerHTML = "Equal to 10"
  }
  else {
    document.getElementById("demo").innerHTML = "Not equal to 10"
  }
}
</script>

</body>
</html>
```