Created
July 2, 2019 21:53
-
-
Save pajaro5/637add2fd438e7cbdd3fefa972121898 to your computer and use it in GitHub Desktop.
Ejemplo del uso de foreach en un array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>Muestra todos los elementos de un array, con sus claves y valor</p> | |
<p id="demo"></p> | |
<script> | |
var frutas = ["manzana", "naranja", "pera"]; | |
frutas.forEach(repetidor); | |
function repetidor(item, index) { | |
document.getElementById("demo").innerHTML += index + ":" + item + "<br>"; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment