Foreach creates a loop that goes round and round for each x element it cycles through each line in the array.
Condition allows us to restrict amount of lines/loops to a specific rule
Our rule is x must be greater than 2
Because tutorial says if player attempts level he gets a 1, if he wins the level he gets a 2, if he wins and gets 1 star, he gets 3, wins and 2 stars, he gets 4 and if he wins and gets max stars he gets 5
Its just a number.
We know that 2 of the 5 is not stars so we want to subtract the 2 to get the remainder.
x = 3 player has 1 star 3-2=1
x = 4 player has 2 stars 4-2=1
x = 5 player has 3 stars 5-2=3
So we loop through each x element that is greater than 2
We add total x number to a total variable
we also add 1 to count number of times it cycles (this is number of x entries that have stars.
No we do the same. Total -2 = stars but I did it a litle different
Total - (numberlevelswithstars*2)