I have a problem and I can't find an answer for that issue, I want to add/sum all values from points in points_sum.
I tried to do this by adding a for loop in the object, but then I get:
'Unexpected token'
How can I do this in the another way?
let sum = 0;
let teams = [
team1 = {
name: "Real",
goal_plus: [3, 4, 2, 1],
goal_minus: [1, 0, 2, 1],
points: [3, 3, 3, 1],
points_sum: for (let i = 0; i < points.length; i++) {
sum += points[i];
}
},
team2 = {
name: "Barca",
goal_plus: [5, 2, 5, 1],
goal_minus: [1, 0, 0, 1],
points: [3, 3, 3, 1],
points_sum: 0
}
]