> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/arr/ext/arr.padendspaces.md).

# arr.padEndSpaces()

[JS](/web/js.md) ⟩ [objects](/web/js/val/obj.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ [methods](/web/js/val/builtin/arr/method.md) ⟩ padEndSpaces()

{% hint style="success" %}
主要用於準備 [Google Sheet](/web/appendix/gas/google-sheet.md) 表格的<mark style="color:yellow;">**列資料**</mark> (row)。
{% endhint %}

{% tabs %}
{% tab title="💾 程式" %}
:floppy\_disk: replit: [arr.padEndSpaces()](https://replit.com/@pegasusroe/arrpadEndSpaces#index.js)

```javascript
// 🔸 arr.padEndSpaces(n)
/**
 * pad spaces ("") to the end of array
 * 
 * @example
 * 
 *   const a = ['班級','座號','姓名'];
 *   a.padEndSpaces(3),        // [ '班級', '座號', '姓名', '', '', '' ]
 * 
 */
Array.prototype.padEndSpaces = function(n) {
    return this.concat(Array(n).fill(''));
};
```

💈範例：

```javascript
const a = ['班級','座號','姓名'];
a.padEndSpaces(3),        // [ '班級', '座號', '姓名', '', '', '' ]
```

{% endtab %}

{% tab title="⬇️ 應用" %}

* [國中成績一覽表](/web/appendix/gas/projects/guo-zhong-cheng-ji-yi-lan-biao.md) - 用於準備表格的<mark style="color:yellow;">**列資料**</mark> (row)。
  {% endtab %}
  {% endtabs %}
