'How can a make a forEach loop wait for value to proceed in Javascript?

const arr = [ {name: "john", chosenItem: ""}, {name: "jimmy", chosenItem: ""}];

arr.forEach(element => {
   element.chosenItem = choose();
})

function choose() {
if("CHOOSE A")
   return "A"
else("CHOOSE B")
   return "B"
}

every loop it ask for a decision then proceeds to the other one after choosing.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source