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

204
Views
¿Cómo recorrer una matriz y mostrar la entrada del usuario con índices?

¿Cómo recorro una matriz y muestro la entrada del usuario con índices sin que la entrada del usuario se replique?

Salida actual que estoy obteniendo:

Comentarios 1

123456

Comentarios 2

123456

El resultado esperado para el caso siguiente debe ser:

Comentarios 1

123

Comentarios 2

456

 <!DOCTYPE html> <html> <head> <script src="script.js" type="text/javascript"> </script> </head> <body> <h2>Feedback Form</h2><br> <form> Enter Feedback : <textarea rows="3" cols="20" id="feedback"></textarea><br><br> <input type="button" value="Submit Feedback" id="create" onclick="addFeedback()"><br><br> <input type="button" value="View Feedback" id="view" onclick="displayFeedback()"><br><br> </form> <div id="result"></div> </body> </html>
 var myArray = []; var myFeedback = document.getElementById("feedback"); var displayBox = document.getElementById("result"); function addFeedback(){ //Store feedback into array myArray.push(myFeedback.value); //Clear textbox myFeedback.value = ""; //Display message displayBox.innerHTML = "Successfully Added Feedback Details!"; } function displayFeedback(){ displayBox.innerHTML = ""; for(var i = 0; i < myArray.length; i++){ displayBox.innerHTML += "Feedback " + (i+1) + "<br/>" + myArray.join(); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use myArray[i] en lugar de join . O un enfoque más moderno:

 let innerHTML = "<ul>"; myArray.forEach((value, index) => { innerHTML += `<li>Feedback ${index+1}: <br /> ${value}</li>`; }); innerHTML += "</ul>"; displayBox.innerHTML = innerHTML;
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!