[Solved] I want to loop through an array but I don’t want to use for


You can use Array.prototype.map for this. In your case:

suspects.map((name) => {
    let suspectObj= CreateSuspectObjects(name);
    suspectsList.push(suspectObj);
});

If you need the index in the future you can also do:

suspects.map((name, idx) => {
    let suspectObj= CreateSuspectObjects(name);
    suspectsList.push(suspectObj);
});

4

solved I want to loop through an array but I don’t want to use for