logkeys has value ['client', 'manager', 'server', 'public', 'network']
checkedData has value {0: 'infomqttclient', 1: 'warnconfigmanager', 2: 'errorwebserver',
3: 'warnpubsusb', 4: 'errornetwork'}
masks has value ['info', 'warn', 'error', 'threadentry', 'tracefunc']
I want to run a loop through checkedData and find the relevant index of the value by mapping it with masks.
For eg: infomqttclient has ‘info’ in it which is one of the entries in mask. So, I want to return 0, which is the index of ‘info’ inside mask
Here’s the code
const checkedData = ref([])
const masks = ref(['info', 'warn', 'error', 'threadentry', 'tracefunc'])
const applyChanges = () => {
// logkeys has value ['client', 'manager', 'server', 'public', 'network'].
checkedData has value {0: 'infomqttclient', 1: 'warnconfigmanager', 2: 'errorwebserver',
3: 'warnpubsusb', 4: 'errornetwork'}
let logKeys = Object.keys(logData.value)
for (var k = 5, i = 0; i < 5; i++, k--) {
for (var i = 0; i < 5; i++) {
if (checkedData.value[i].includes(tracelogKeys[i])) {
// const index = tracelogKeys.map((e) => e).indexOf(tracelogKeys[i])
}
}
}
}
I’m struggling with the mapping part and if this code could be more optimised. I’m also facing some typescript warnings. How do I do the mapping in the optimal way?