⛄Snowberb⛄ – 12-54 Jan 27

What's a better way to do this instead of nesting 2 loops?
for (const template of instrumentTemplates) {
const { instrumentTypeId, name, instrumentTemplate } = template;

for (const instrument of instruments.data) {
if (instrument.instrumentTypeId === instrumentTypeId) {
instrumentsWithTemplate.push({ ...instrument, instrumentTemplate, instrumentType: name });
}
}
}
for (const template of instrumentTemplates) {
const { instrumentTypeId, name, instrumentTemplate } = template;

for (const instrument of instruments.data) {
if (instrument.instrumentTypeId === instrumentTypeId) {
instrumentsWithTemplate.push({ ...instrument, instrumentTemplate, instrumentType: name });
}
}
}
Unknown User
Unknown User478d ago
Message Not Public
Sign In & Join Server To View