Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save claudiainbytes/5fbe0a475e716b4515de29e7e691c7df to your computer and use it in GitHub Desktop.
Save claudiainbytes/5fbe0a475e716b4515de29e7e691c7df to your computer and use it in GitHub Desktop.
JS - Labeling loops/Rotulación de ciclos
var abc = "a,b,c,d,e,f,g,h,i,j,k,l";
abc = abc.split(",");
c = 0;
var matrix = [];
for (var i = 0; i < 3; i++){
var fila = [];
for(var j = 0; j < 4; j++){
fila[j] = abc[c];
c++;
}
matrix[i] = fila;
}
console.log(matrix);
var matrix2 = [];
for_label_principal:
for (var i = 0; i < 3; i++){
var fila2 = [];
for(var j = 0; j < 4; j++){
fila2.push(matrix[i][j]);
if( j == 1 ){
continue for_label_principal;
}
matrix2.push(fila2);
}
}
console.log(matrix2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment