【MACRO】Google Apps Script 質問スレ【DRIVE】at TECH
【MACRO】Google Apps Script 質問スレ【DRIVE】 - 暇つぶし2ch917:デフォルトの名無しさん
23/02/21 23:07:45.74 6tAoYaOK.net
>>915
>そのarray[i][j]の[j]を入れるとindexOfにしてもincludesにしてもうちの環境?では何故かエラー出て
たぶん配列の添字が範囲外になってるんだろうけど
for文よりfor ofとかforEachのほうがシンプルにかける
const array2 = [];
for(let row of array) {
let cols = [];
for(let col of row) {
if(before.includes(col)) {
cols.push(after[before.indexOf(col)]);
}
else {
cols.push(col);
}
}
array2.push(cols);
}
const array2 = [];
array.forEach(function(row, i) {
row.forEach(function(col, j) {
if(before.includes(col)) {
array[i][j] = after[before.indexOf(col)];
}
});
});


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch