【MACRO】Google Apps Script 質問スレ【DRIVE】 (968レス)
前次1-
抽出解除 レス栞

908
(1): 898 [sage] 2023/02/21(火)08:58 ID:B3qxCQs3(2/3)
>>907
そのarray[i][j]の[j]を入れるとindexOfにしてもincludesにしてもうちの環境?では何故かエラー出て読み込めなかったんですよ。(
確かcannot read properties of undefinedだった筈)
それ外すとエラーなく読んだので仕方なくflat入れた次第です。
因みに
arrayX=array[x]
arrayY=array[y]
みたいに入れ子しても駄目でした。
910
(1): デフォルトの名無しさん [sage] 2023/02/21(火)23:07 ID:6tAoYaOK(2/3)
>>908
>その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-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.032s