Skip to content

Instantly share code, notes, and snippets.

@jerlyrosa
Created September 15, 2020 01:05
Show Gist options
  • Save jerlyrosa/d10fe9d038e3b1f965ff4f9d876135da to your computer and use it in GitHub Desktop.
Save jerlyrosa/d10fe9d038e3b1f965ff4f9d876135da to your computer and use it in GitHub Desktop.
Funcionamiento del metodo Array.prototype.forEach()
// Array.prototype.forEach()
// El método forEach() ejecuta la función indicada una vez por cada elemento del array.
const arr = ['lunes', 'Martes', 'Miercoles', 'Jueves','Viernes', 'Sabado', 'Domingo'];
const newList = arr.forEach( (element, index) =>{ // elemet = a los elemnto de arr index pues la posicion.
console.log( `<li id="${index}"> ${element}</li>`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment