mardi 22 décembre 2015

Else statement won't work in for loop

I have a function here that is not working as I hoped it would. After a bit of testing, I discovered that it is not running the "else if" statement. Here is the code:

getWeights : function() {
    weights = [];
    for (var i = 0; i < hiddenLayer.length; i++) {
        weights[i] = {};
        for (var j = 0; j < Object.keys(hiddenLayer[i]).length * 3; j++) {
            if (i == 0) {
                for (var t = 0; t < input.length; t++) {
                    weights[i]["weightsSet" + j] = 1;
                }
            }
            else {
                weightCalc = Object.keys(hiddenLayer[i - 1]).length;
                for (var u = 0; u < Object.keys(hiddenLayer[i]).length * weightCalc; u++) {
                    weights[i]["weightsSet" + j] = 1;
                }
            }
        }
    }
},

Please help me find out why it won't work. Any help is greatly appreciated.

EDIT Removed comment

Aucun commentaire:

Enregistrer un commentaire