Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
971 B
1
Indexable
Never
var flipAndInvertImage = function(image) {
    var flip = [];
    var reverse = [];
    var output = [];
    var slice1 =[];
    var slice2 = [];
    for(var countSlice = 0; countSlice<image.length;countSlice++){
        var index = 1;
         slice1 = image.slice(countSlice,index);
         slice2 = slice1[countSlice];
        var w =Object.keys(slice2).length;
       for(var countFlip = w-1;countFlip >=0;countFlip--){
            flip.push(slice2[countFlip]);
        }
        for(var countReverse = 0;countReverse<flip.length;countReverse++){
            if(flip[countReverse]==0){
                reverse.push(1);
            }else if(flip[countReverse]==1){
                reverse.push(0);
            }
            
        }
        output.push(reverse);
        slice1.length=0;
        slice2.length=0;
        index++;
        flip.length=0;
        reverse.length=0;
        var y  = reverse;
    }

    return output;
};