「Google Apps Script」repeatメソッドで文字列を繰り返すサンプル

2022年6月24日

構文
文字列.repeat(count)
指定回数(count)で文字列を繰り返します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function myFunction() {
const strA = "あ";
console.log(strA.repeat(2));
const strB = "テスト";
console.log(strB.repeat(2));
}
function myFunction() { const strA = "あ"; console.log(strA.repeat(2)); const strB = "テスト"; console.log(strB.repeat(2)); }
function myFunction() {
 
  const strA = "あ";
  console.log(strA.repeat(2)); 

  const strB = "テスト";
  console.log(strB.repeat(2)); 
}

実行結果
ああ
テストテスト

Google Apps Script

Posted by arkgame