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

170
Views
Hola, en este código necesito encontrar el lugar exacto de las letras, mi código encuentra solo el lugar de una letra, pero quiero encontrar el lugar de 2 o más letras
const f = (newStr, givenWord) => { let arr = [...newStr]; let newArr = []; for (let i = 0; i + Math.sqrt(arr.length) < arr.length + 1; i += Math.sqrt(arr.length)) { newArr.push(arr.slice(i, i + Math.sqrt(arr.length))) } console.log(newArr); for (let i = 0; i < newArr.length; i++) { for (let j = 0; j < newArr[i].length; j++) { if (newArr[i][j] == givenWord) { return [i, j]; } } } return [-1, -1]; }; let result = f("QWEASDZXC", "A"); console.log(`[${result[0]} ${result[1]}]`);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba con este enfoque

 (function(word, letters) { // Convert letters words in an array with indexes of each letter in the word const indexes = letters.split('').map(letter => word.indexOf(letter)); return indexes.filter(index => index !== -1); })('QWEASDZXC', 'AC');

Aporte

 'QWEASDZXC' 'AC'

Salida recibida

 [ 3, 8 ]
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!