/* La variable "elementos" recibe la array */
function mostrarArray(elementos, textoCustom = "") {
document.write("<h1>Os presentamos el contenido de la array "+textoCustom+"<h1>");
miarray.forEach((elemento, indice)=>{
document.write("<strong>"+elemento+"</strong><br/>");
});
}
/* La variable "elementos" recibe la array */
function mostrarArray(elementos, textoCustom = "") {
document.write("<h1>Os presentamos el contenido de la array "+textoCustom+"<h1>");
elementos.forEach((elemento, indice)=>{
document.write("<strong>"+elemento+"</strong><br/>");
});
}
'use strict'
/*
1- Pedir 6 numeros por pantalla y meterlos en una array
2- Mostrar el array entero (todos sus elementos) en el cupero de la pagina y en consola
3- Ordenarlo y mostrarlo
4- Invertir su orden y mostrarlo
5- Mostrar cuantos elementos tiene la array
6- Busqueda de un valor introducido por el usuario, que nos diga si lo encuentra y si es asi su indice
(Se valora el uso de funciones)
*/
/* La variable "elementos" recibe la array nose la utilidad */
function mostrarArray(elementos, textoCustom = "") {
document.write("<h1>Os presentamos el contenido de la array "+textoCustom+"<h1>");
numeros.forEach((elemento, indice)=>{
document.write("<strong>"+elemento+"</strong><br/>");
});
}
// Apartado 1
var numeros = new Array(6);
numeros = [];
for(var i = 0; i <=5; i++) {
numeros.push(parseInt(prompt("Introduce un numero")));
}
// Apartado 2
mostrarArray(numeros);
console.log(numeros);
// Apartado 3
numeros.sort((a,b)=>{return a-b;});
mostrarArray(numeros, "ordenado");
function mostrarArray(elementos, textoCustom = "") {
document.write("<h1>Os presentamos el contenido de la array "+textoCustom+"<h1>");
elementos.forEach((elemento, indice)=>{
document.write("<strong>"+elemento+"</strong><br/>");
});
}
function mostrarArray(textoCustom = "") {
document.write("<h1>Os presentamos el contenido de la array "+textoCustom+"<h1>");
numeros.forEach((elemento, indice)=>{
document.write("<strong>"+elemento+"</strong><br/>");
});
}
mostrarArray('Aquí el texto de la variable textoCustom');