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
declaración de retorno no devuelve nada en javascript

Dada una cuadrícula de caracteres en el rango ascii[az], reorganice los elementos de cada fila alfabéticamente, de forma ascendente. Determine si las columnas también están en orden alfabético ascendente, de arriba a abajo. Devuelva SÍ si lo son o NO si no lo son.

 const gridOrig = ["ebacd", "fghij", "olmkn", "trpqs", "xywuv"]; function gridChallenge(grid) { // Write your code here let gridOne = []; let gridTwo = []; for (let i = 0; i < grid.length; i++) { gridOne.push(grid[i].split("")); // console.log(gridOne); }//this section makes each element of the array become array for (let i = 0; i < gridOne.length; i++) { gridTwo.push(gridOne[i].sort()); // console.log(gridTwo); }//this section sort each element of the parent array let answer = []; for (let i = 0; i < gridTwo.length - 1; i++) { for (let j = 0; j < gridTwo[i].length; j++) { if (gridTwo[i][j] <= gridTwo[i + 1][j]) { // debugger; // console.log("true"); answer.push("YES"); } else if (undefined) { answer = "NO"; } else { // console.log("false"); answer.push("NO"); } } } // console.log(answer); let finalAns = "NO"; if (answer.includes("NO")) { finalAns = "NO"; } else { finalAns = "YES"; } console.log(finalAns); //I can see it on the console return finalAns; // this returns nothing } gridChallenge(gridOrig);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Devuelve el resultado, simplemente no lo usas. Prueba esto:

 const gridChallengeResult = gridChallenge(gridOrig); // saving returned value to variable console.log(gridChallengeResult) // logging it to the console
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!