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

208
Views
¿Cómo escribir un programa javascript que devuelva el subconjunto de una cadena como una matriz?

He visto ejemplos, pero todavía no entiendo todo. Sé que substring() definitivamente se usa, pero necesito un desglose paso a paso si es posible. Muchísimas gracias :)

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

0

Primero puede dividir la cadena usando el método String.split() y luego puede crear combinaciones con los elementos presionando una nueva matriz.

Demostración de trabajo:

 // Input string let str = "dog"; // An empty array which will store the combinations. let result = []; /** * getCombination() method is used to get all the combinations of all the array elements passed as a parameter. */ function getCombination(inputArr) { // variable which will store the combination string. let temp = ''; // Iterating input array to get elements one by one. inputArr.forEach((elem, index) => { // Pushing the element into result array. result.push(temp + elem); // To make the combination updating temp variable with the elem. temp += elem + ""; }); } // Once combination done for one iteration, removing the first element from an array and then again calling getCombination() method to get the combination for next set of elements. str.split('').forEach((elem, index) => { getCombination([...str.slice(index)]); }); // Expected result console.log(result);

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!