Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Cómo eliminar una matriz de una matriz anidada, recorrer el resto de las matrices. Y luego recorra 1 valor de las matrices anidadas, todo en vanilla js
let linkMatrix = [ [0,0,1,0], [1,0,0,1], [1,1,0,1], [0,1,0,0] ]; let newMatrix = []; function linkToPage(){ for(let j = 0; j < linkMatrix.length; j--){ newMatrix = linkMatrix.splice(linkMatrix[j], 1); console.log(linkMatrix + " Here is linkMatrix"); for(let i = 0; i < newMatrix.length; i++){ newMatrix.splice(newMatrix[i]); console.log(newMatrix + " Here is newMatrix"); } }

** Lo que estoy tratando de hacer es recorrer la primera matriz pero eliminar la primera matriz, porque no necesito recorrer eso, luego recorrer el resto de las matrices, pero el único valor que necesito es el valor en el índice de la matriz eliminada, para comprender mejor: si tuviéramos una matriz que usara algo como esto arr = [[0,1],[1,0],[1,1]] entonces elimine [0,1] y porque es arr[0], me gustaría recorrer el índice 0 de las otras matrices para obtener 1 y 1, luego volver a la matriz original eliminar arr[1] y recorrer arr[0],arr [2] al índice 1 de las matrices para obtener [1,1] **

 **Yeah, so the wanted result from my link matrix would be: [0,0,1,0] = 2 [1,0,0,1] = 2 [1,1,0,1] = 1 [0,1,0,0] = 2 because there is 2 other arrys pointing to the first array, the same for the second and fourth, but there is only one array pointing to the third array **
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede agregar los valores de las columnas.

 const getColSum = matrix => matrix.reduce((r, a) => a.map((v, i) => (r[i] || 0) + v), []); console.log(...getColSum([[0, 0, 1, 0], [1, 0, 0, 1], [1, 1, 0, 1], [0, 1, 0, 0]])); console.log(...getColSum([[0, 0, 0], [1, 0, 0], [1, 1, 0]]));

Una versión sin (casi) métodos de matriz.

 function getColSum (matrix) { const result = Array(matrix[0].length).fill(0); for (const row of matrix) { for (let i = 0; i < row.length; i++) result[i] += row[i]; } return result; } console.log(...getColSum([[0, 0, 1, 0], [1, 0, 0, 1], [1, 1, 0, 1], [0, 1, 0, 0]])); console.log(...getColSum([[0, 0, 0], [1, 0, 0], [1, 1, 0]]));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!