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

148
Views
¿Puedo usar un argumento de funciones como prefijo para un nombre de variable? miFunción(id) { idvarName}

Editar: lo que funcionó para mí (como se sugirió) fue usar las matrices como argumentos en la llamada a la función ...

 let navText = ['House', 'Food', 'Work']; let navLinks = ['house.html', 'food.html', 'work.html']; function navBuilder(id, textList, linkList) { // Getting the element with the id navList = document.getElementById(id); // let openTag = document.innerHTL // looping through the arrays and matching the text with the link for (let i = 0; i < textList.length; i++) { listItem = document.createElement('li'); // adds classes listItem.className = id + '_list_item'; linkClass = id + "_list_link"; // put it all together listItem.innerHTML += "<a href=\"" + linkList[i] + "\" class=\"" + linkClass + "\">" + textList[i] + "</a></li>"; navList.appendChild(listItem); } } // Call the function here or include it in a script tag at the end of the html. navBuilder("nav", navText, navLinks);

¡Gracias por la ayuda!

 let navText = ['House', 'Food', 'Work']; let navLinks = ['house.html', 'food.html', 'work.html']; function navBuilder(id, textList, linkList) { // Getting the element with the id navList = document.getElementById(id); // let openTag = document.innerHTL // looping through the arrays and matching the text with the link for (let i = 0; i < textList.length; i++) { listItem = document.createElement('li'); // adds classes listItem.className = id + '_list_item'; linkClass = id + "_list_link"; // put it all together listItem.innerHTML += "<a href=\"" + linkList[i] + "\" class=\"" + linkClass + "\">" + textList[i] + "</a></li>"; navList.appendChild(listItem); } } // Call the function here or include it in a script tag at the end of the html. navBuilder("nav", navText, navLinks);

Fue solo una ligera modificación de lo que estaba haciendo al principio. Seguro que era un problema de hacha e y.

about 4 years ago · Juan Pablo Isaza
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!