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

138
Views
codeademy de reverseArray() usando unshift()
// Using the .unshift() method
 const reverseArray = arr => { let reversed = []; for (let i = 0; i < arr.length; i++) { reversed.unshift(arr[i]); } return reversed }

si queremos invertir el orden, el último elemento se convertirá en el primero. ¿Cómo puede este método invertir el orden cuando comienza en el primer índice?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Basado en esto :

El método unshift() agrega nuevos elementos al comienzo de una matriz y devuelve la nueva longitud

Entonces, en cada iteración, está agregando un elemento al comienzo de una matriz y cuando finaliza la iteración, ha invertido la matriz.

about 4 years ago · Juan Pablo Isaza Report

0

"array.unshift()" se usa para insertar elementos en la matriz, debe usar "array.reverse()" para invertir la matriz.

 const arr = [1, 2, 3]; arr.unshift(4, 5); console.log(arr); // reverse arr.reverse(arr, "this is unshift"); console.log(arr, "this is reverse"); // output: arr [4, 5, 1, 2, 3]

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!