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

111
Views
Estoy tratando de concatenar el segundo parámetro con el primero en JS

Estoy bastante atascado, debería evaluarse como ["present", "pretty", "precede"]

 function addTooStart(x, y) { let a = []; let b = ""; for (let i in x) { a = x.push(y); a = x[b] } return a } let abc = addTooStart(["sent", "tty", "cede"], "pre"); console.log(abc)

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

0

No estoy seguro de lo que su a y b intentan hacer aquí. Algunos problemas de su código:

  1. x.push(y) agrega el elemento y al final de la matriz x, y luego devuelve la nueva longitud de la matriz, por lo que ahora a es un número.
  2. x[b] siempre será una llamada inválida, ya que b es igual a la cadena vacía y nunca se cambia, las matrices se indexan como enteros.

El enfoque general aquí sería recorrer la matriz x, como lo hizo, luego, para cada elemento, establecerlo igual a "y + elemento actual". He adjuntado una versión de trabajo a continuación.

 function addToStart(x,y){ for (let i = 0; i < x.length; i++) { x[i] = y + x[i] } return x } addToStart([ "sent", "tty", "cede" ], "pre"); // -> [ 'present', 'pretty', 'precede' ]
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!