Javascript Array And Array Operations Matlab For Loop