Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
Function can accept character input and the number of loop

i have some question about logic,but i stuck in this question. i dont understand what this question means

Write a function with the following conditions:

  • Function can accept character input and the number of loop
  • Each of the first characters will be taken out from the string and input into a new string
  • Then every the number of inputs loop take out from the string and input into a new string
  • Do this until the characters in the string empty
  • Return the New Of String

Example:

function solution(string, numberOfLoop)
solution("MISTERALADIN",4) Output: MEAIANLTSRID

function Solution(string, numberOfLoop) {
  let newString = string[0];
  for (let i = 0; i < numberOfLoop; i++) {
    string = string.subs
    for (let j = 0; j < string.length; j++) {
      newString += string[j];
    }
  }
}

// function Solution (string, numberOfLoop) {
//   // console.log(string)
//   let newString = string[0]

// }

console.log(Solution("MISTERALADIN", 4));

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem is very poorly written, apparently by someone who doesn't speak English well (unless you did the translation, then maybe you didn't translate it well).

The parameter "number of loop" doesn't really describe it well. It's not the number of iterations to perform, so you don't use it as the limit in a for loop.

Based on the example, it's the steps between characters to select. So it's the increment that you should add to to the iteration variable in the loop. The limit is the length of the string.

So what you're supposed to do is:

  1. Copy the characters at indexes 0, numberOfLoop, 2*numberOfLoop, 3*numberOfLoop, etc. to the result, and remove them from the input string.

  2. Repeat the above step until the input string is empty.

I'm not writing the solution for you. You asked what the question means, solving it is still your problem.

It will probably be easier to do this by first converting the string to an array (you can do this with the split() method), then you can use splice() to remove elements from it.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda