Not readable function at all in Javascript and no comments

Member

carey

by carey , in category: JavaScript , 2 months ago

Not readable function at all in Javascript and no comments! Is anyone able to read and understand it ? 😗

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
scope.doOperation = function(i) {
  var arrayOperation = scope.operations[0].split(' ')
  if (arrayOperation[0] == 'UPDATE') {
    var x = arrayOperation[1]
    var y = arrayOperation[2]
    var z = arrayOperation[3]
    var w = arrayOperation[4]
    scope.elements[x][y][z] = w
  } else if (arrayOperation[0] == 'QUERY') {
    var x1 = arrayOperation[1]
    var y1 = arrayOperation[2]
    var z1 = arrayOperation[3]
    var x2 = arrayOperation[4]
    var y2 = arrayOperation[5]
    var z2 = arrayOperation[6]
    var sum = 0
    for (var x = x1; x <= x2; x++) {
      for (var y = y1; y <= y2; y++) {
        for (var z = z1; z <= z2; z++) {
          sum += parseInt(scope.elements[x][y][z])
        }
      }
    }
    scope.sampleOutput = scope.sampleOutput + sum.toString() + '\n'
  }
  scope.operations.shift()
}

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers