I am tasked to write a function that returns the missing uniform pieces of Company A or Company B. The function should look thru the array to determine which Company is the one with the missing piece. Can I use another loop inside forEach in Javascript? or is it best i use to separate loops? Any hints are appreciated.
function findCompanyName(uniformSet, uniformPieces) {
uniformPieces.forEach((element) => {
const splitedArrayUniPcs = element.split("_");
});
//return "example";
}
findCompanyName(
["shirt", "pants"],
["companyA_shirt", "companyA_pants", "companyB_shirt"]
); //return companyB
>Solution :
Can I use another loop inside forEach in Javascript?
Yes! There is nothing wrong with nested loops in Javascript.