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

150
Vistas
¿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
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