Respuestas Ejercicio 20 (JS Septiembre 2022)

Comparte tu respuesta del ejercicio 20

https://github.com/makeitrealcamp/intro-javascript-sept-2022/blob/main/dia-4.md

Nota: Recuerdas que puedes formatear el bloque de codigo que compartas agregando 3 backticks, comillas francesas, o tildes al reves
Ejemplo:

console.log('hola')
console.log('mundo')
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
let i = 1

for(arreglo of mat){
  console.log("Grupo " + i + ":")
  for(elemento of arreglo){
    console.log("  " + elemento)
  }
  i++
}
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

for (let i=0; i < mat.length; i++) {
  console.log("Grupo " + (i+1) + ":");
  for (let j=0; j < mat[i].length; j++) {
    console.log("  " + mat[i][j]);
  }
}
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
for(let index=0; index<mat.length;index++){
  console.log("Grupo ", index+1, ":")
  for(let index2=0; index2<1;index2++){
     console.log("")
     for(let index3=0; index3<mat.length;index3++){
        console.log("", mat[index][index3])
      }
   }
      
}
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

for(let i=0;i<mat.length;i++){
  console.log("Grupo "+(i+1)+":")
  for(let j=0;j<mat[0].length;j++){
    console.log("  "+mat[i][j])
  }
}
// Declarar array con datos que son arrys
const mat = [ //array principal
  ["Pablo", "Maria", "Pedro"], //array 1
  ["Diana", "Juan", "Federico"], //array 2
  ["Roberto", "Daniel", "Sandra"] //array 3
]

// Crear bucle forr anidados para poder acceder a los arrays dentro del array principal
for(let indexA = 0; indexA < mat.length; indexA++){
  console.log('Grupo ', indexA+1) // iMprime un anuncio
  for(let indexB = 0; indexB < mat.length; indexB++){
    console.log(' ',mat[indexA][indexB]) //Imprime dato de los arrays dentro del array princiapl
  }
}

Código ejercicio 20:

const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
for (let i = 0; i < mat.length; i++) {
  console.log("Grupo "+(i+1)+":")
  for (let j = 0; j < mat[i].length; j++) {
    console.log("  ",mat[i][j])
  }
}
/*Ejercicio 20*/
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
for(let i=0;i<mat.length;i++){
  console.log("Grupo "+(i+1)+":");
  for(let name of mat[i]){
    console.log("  "+name)
  }
}

const mat = [
[“Pablo”, “Maria”, “Pedro”],
[“Diana”, “Juan”, “Federico”],
[“Roberto”, “Daniel”, “Sandra”]
]
for (let i = 0;i < mat.length; i++){
console.log(‘Grupo’, i + 1,‘:’)
for (let j = 0;j < mat[i].length; j++){
console.log(mat[i][j])
}
}

les comparto mi código

const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

let auxArray = [];

for(let i = 0; i < mat.length; i++){
  auxArray = mat[i];
  console.log('Grupo ' + (i+1));
  for(let j=0; j<auxArray.length;j++){
    console.log('  ' + auxArray[j]);
  }
}

const mat = [
[“Pablo”, “Maria”, “Pedro”],
[“Diana”, “Juan”, “Federico”],
[“Roberto”, “Daniel”, “Sandra”]
];
for (let i = 0; i < mat.length; i++) {
console.log(‘Grupo ’ + (i + 1) + ‘:’);
for (let j = 0; j < mat[i].length; j++) {
console.log(’ ',mat[i][j]);
}
}

1 me gusta
console.log('***RECORRIDO MATRIZ***');

const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];


for(i=0;i<mat.length;i++){
  console.log('Grupo' + ' ' +(i+1)+':');
  for (let grupo of mat[i]){
  console.log('  '+ grupo);
}
};
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

for (let i =0; i<mat.length; i++){
  const matAux = mat[i]
  console.log("Grupo "+ (i+1) + ":")
  
  for(let j=0; j<matAux.length; j++){
  console.log(" ", matAux[j])
  } 
}
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

for (let i=0; i < mat.length; i++) {
  console.log("Grupo " + (i+1) + ":");
  for (let n=0; n < mat[i].length; n++) {
    console.log("  " + mat[i][n]);
  }
}

Saludos, esta es mi respuesta.

const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
let cont = 1

for(let arr of mat){
  console.log("Grupo",cont); cont++
  for(let name of arr) console.log("  ",name)
}
1 me gusta

/*
Ejercicio 20
*/

const mat = [
[“Pablo”, “Maria”, “Pedro”],
[“Diana”, “Juan”, “Federico”],
[“Roberto”, “Daniel”, “Sandra”]
];
let i = 1

for(lista of mat){
console.log(“Grupo " , i , “:”)
for(elemento of lista){
console.log(” " , elemento)
}
i++
}

Mi respuesta al Ejercicio 20:

console.log('Listado de grupos.')
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];
for (let group of mat) {
  console.log(`Grupo ${mat.indexOf(group) + 1}:`);
  for (let name of group) {
    console.log(`  ${name}`);
  }
}
//ejercicio 20
const mat = [
  ["Pablo", "Maria", "Pedro"],
  ["Diana", "Juan", "Federico"],
  ["Roberto", "Daniel", "Sandra"]
];

console.log(mat)
for(let i=0; i < mat.length ;i++){
  console.log("Grupo "+ (i+1) + " :")
  for (let j=0; j < mat[i].length ;j++) {
    console.log("  "+ mat[i][j])
   } 
}

const mat = [
[“Pablo”, “Maria”, “Pedro”],
[“Diana”, “Juan”, “Federico”],
[“Roberto”, “Daniel”, “Sandra”]
];

for (let i=0; i<mat.length; i++){
console.log(“Grupo " + (i+1) + " :”)

for (let j=0; j<mat[i] .length; j++){

console.log( mat [i] [j] )

}
console.log(“\n”)
}