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

350
Views
Para finalizar la función scrollingText(word)

Estoy escribiendo un programa donde quiero el siguiente resultado:

[ 'ROBOT', 'OBOTR', 'BOTRO', 'OTROB', 'TROBO' ]

Ahora tengo:

[ 'robotr', 'obotr', 'botr', 'otr', 'tr' ]

¿Dónde me estoy equivocando? Aquí está mi código:

 function scrollingText(word) { word = word.toUpperCase(); let arr = []; for (let i = 0; i < word.length; i++) { arr.push(word[i] + word.slice(i + 1) + word[0]); } return arr; } console.log(scrollingText('robot'));

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

0

Debe actualizar la word en cada iteración, y no simplemente slice la misma word repetidamente. Aquí está mi fragmento:

 function scrollingText(word) { let arr = [word.toUpperCase()]; // storing original word let wordLength = word.length; for (let i = 0; i < wordLength - 1; i++) { // iterating for one less than the string length, in this case, from 0 to 3 word = word.slice(1) + word[0] // <<-- update word in every iteration arr.push(word.toUpperCase()); } return arr; } console.log(scrollingText('robot'));

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!