# str.removeWhitespaces()

{% tabs %}
{% tab title="💾 程式" %}
```javascript
// 🔸 str.removeWhitespaces()
String.prototype.removeWhitespaces = function() {
    return this.replace(/\s+/g, '');
};
```

💈範例：

```javascript
// multi-line string
let str = `
as     void     async     while
`;

str.removeWhitespaces()    // "asvoidasyncwhile"
```
{% endtab %}

{% tab title="👥 相關" %}
* [str.replacewhitespaces](str.replacewhitespaces "mention") - replace white-spaces with specific delimiter.
{% endtab %}

{% tab title="⬇️ 應用" %}
* [no-make-up-exam](../../../../../appendix/gas/projects/no-make-up-exam "mention")
* [class-average](../../../../../appendix/gas/projects/class-average "mention")
{% endtab %}
{% endtabs %}
