How to find value of a 2-d array then add to an array depending on the value of 2-d array

时间:2016-07-11 20:31:23

标签: javascript multidimensional-array onchange selectedindex

I'm having Trouble trying to add a value to a counter of a character object depending on the value in the 2-d array of characters. There are multiple characters and I'm trying to find which character has the biggest counter.

function pushA() {
    for(var i = 0; i < characters.length; i++) {

characters is a 2-d array the has might have a value of 1 in an index depending on the selectedindex of html code

        if(characters[i].value === 1){

if statement finds which index of 2-d array has a value of 1 and pushes a value to counter

            characters[i].counter.push(1);          
        }
        else{}
    }
    }

    pushA();

The counter is not being added to.

0 个答案:

没有答案