I deconstructed the mergedArr arrays, i is defined as the first array and d as the second. So the d array has all the strings in and the i array has all the numbers in. Which you don’t need to worry about.
If you do this you’ll see:
for (const [i, d] of [mergedArr]) {
console.log(i, d);
}
if you iterate over each element of mergedArr[1] ... check out the following (for demo purpose only !!)
cat test.js
const locUnScr = [3, 5, 7];
const lowerTrimArr = ['Blaaaaaa_Beans', 'Trunked_Split', 'BoooooooooP_goat']
let camCase = [];
let mergedArr = [[...locUnScr], [...lowerTrimArr]];
console.log('mergedArr[1]: <<',mergedArr[1], '>>');
for (let i = 0; i < mergedArr[1].length; i++) {
let tmp=mergedArr[1][i];
camCase.push(tmp.replace(/_/g, '*'));
}
console.log('camCase: <<',camCase, '>>');
# test it
node test.js
mergedArr[1]: << [ 'Blaaaaaa_Beans', 'Trunked_Split', 'BoooooooooP_goat' ] >>
camCase: << [ 'Blaaaaaa*Beans', 'Trunked*Split', 'BoooooooooP*goat' ] >>
hopefully you'll see that it's the individual elements of mergedArr[1] that are strings whereas mergedArr[1] is an array , so string functions barf at that.
You're great at this but I'm in Europe and it's late. I could stay up all night to find out but I'm afraid I'll have to get back to you tomoz. Second solution looks like the one. will test out first thing bro.
so, I'm reasonably confident the code posted works.
' ```
Uncaught ReferenceError: member is not defined
without context (ie the code running) is not particularly helpful at this point.
try the code posted in isolation , if it works, then something elsewhere in your environment/code is causing this - perhaps another js object with the same name ....
you hadn't mentioned the use of strict previously, np, do this then .
for (const [i, d] of [mergedArr]) {
let member = [];
if ( Array.isArray(d) )
for ( member in d ){
if ( typeof d[member] === 'string' )
camCase.push(d[member].replace(/_/g, '*'));
else
camCase.push(d[member]);
}
}