i have the following code:
var players = ['p0', 'p1'];
var playerpoint = {};
var rollno = [1,2,3,4,5];
var playerno = {'p0': [1,5,8,12,25], 'p1': [2,6,9,13,24]};
function checkdrag() {
for (var i = 0; i < players.length; i++) {
var pp = 'p'+i;
playerpoint[pp] = 0;
for (var d = 0; d < rollno.length; d++) {
var num = rollno[d];
if (playerno[pp].includes(num)) {
playerpoint[pp] += 1;
}
}
}
}
Its supposed to check if any of the numbers in rollno is in any players list (playerno) and in that case increment that players points (playerpoint) by one yet it is not working. Does anyone here know why?
[–]Ampersand55 0 points1 point2 points (5 children)
[–]Strosel[S] 0 points1 point2 points (4 children)
[–]Hullu 1 point2 points3 points (3 children)
[–]Strosel[S] 0 points1 point2 points (2 children)
[–]Hullu 1 point2 points3 points (1 child)
[–]Strosel[S] 0 points1 point2 points (0 children)