I am trying to find a logic that i could use with .map() to return the desired value.
Below are 2 variables im using
let _replaceAttr = ['SUM', 'ARRG', 'AGG', 'ATTR', "AVG(pop)"]
let tempData = ['AVG', 'bob', 'sop']
The logic i came with out is returning all as true, if tempData index 0 is set as AVG(pop) , this will return as false.
result = tempData.map(el => !_replaceAttr.includes(el))
console.log(result);
// This logic will not apply the updated array element as it will return all as true
let es6 = tempData.map(w => !_replaceAttr.includes(w) != true ? w.replace(w, '...') : w)
If i were to specifically test this with traditional scripting such as
console.log('AVG(pop)'.includes('AVG')
// This will return as false which is correct
// or
//******* Traditional Script ********
for (let i = 0; i < tempData.length; i++) {
let output = tempData[i]
for (let a = 0; a < _replaceAttr.length; a++) {
if (output.includes(_replaceAttr[a])) {
tempData[i] = tempData[i].replace(_replaceAttr[a], '').replace('(', '').replace(')', '')
}
}
}
console.log(tempData)
The traditional script i have will return the desired output ,i was wondering . Will it be achievable to go with .map() approach on above example.