Regrese de tiempo por temas de trabajo, los 3 ultimos si no pude y me guie del instructor
let listaGenerica = [];
//////////////////////////
let lenguajesDeProgramacion = ['JavaScript', 'C', 'C++', 'Kotlin','Python'];
lenguajesDeProgramacion.push('Java','Ruby','GoLang');
function mostrarElementos () {
console.log(lenguajesDeProgramacion);
}
function mostrarElementosInverso () {
lenguajesDeProgramacion.reverse();
console.log(lenguajesDeProgramacion);
}
//////////////////////////
var listaDeNumeros = [14 , 12 , 13 , 17 , 18 , 15]
function promedioLista (x) {
const initialValue = 0;
const sumWithInitial = x.reduce((accumulator, currentValue) => accumulator + currentValue,
initialValue,
);
console.log(sumWithInitial);
const promedio = sumWithInitial/x.length
return promedio;
}
//////////////////////////////
function filtrarTamano (x) {
var minMax = x.filter((x1) => x1 >=18 || x1 <=12);
return minMax;
}
/////////////////////////////
function sumaLista (x) {
const initialValue = 0;
const sumWithInitial = x.reduce((a, b) => a + b,
initialValue,
);
return sumWithInitial;
}
////////////////////////////
function posicionLista (x) {
const posicion = x.indexOf( parseInt(prompt('Inserte un número de la lista')));
return posicion;
}
////////////////////////////
function encontrarIndiceElemento(lista, elemento) {
for (let i = 0; i < lista.length; i++) {
if (lista[i] === elemento) {
return i; // Retorna el índice del elemento encontrado
}
}
return -1; // Retorna -1 si el elemento no se encuentra en la lista
}
///////////////////////////////////
function sumarListas(lista1, lista2) {
return lista1.map((num, index) => num + lista2[index]);
}
const lista1 = [1, 2, 3];
const lista2 = [4, 5, 6];
const resultado = sumarListas(lista1, lista2);
console.log(resultado);
////////////////////////////////
function cuadradoLista(lista) {
return lista.map(num => num ** 2);
}
const lista = [2, 3, 4];
const resultado1 = cuadradoLista(lista);
console.log(resultado);