i have some issues to randomize an array of objects in a loop.
This is what my code looks like:
this.mealPlan.days.forEach((day) => {
day.meals.forEach((mealTime) => {
console.log('before', mealTime.meals);
//mealTime.meals = this.shuffleArray(mealTime.meals);
mealTime.meals = mealTime.meals.sort(function() {
return Math.random() - Math.random();
});
console.log('after', mealTime.meals);
});
});
My Problem: The before and after looks exactly the same.
Does anyone knows why this happens?
Thanks a lot!