Last active
March 5, 2024 12:03
-
-
Save Demonid/396c3abc7afffc27f12841850e49fcf6 to your computer and use it in GitHub Desktop.
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
let parking = []; | |
function actualizar() { | |
for (let i = 0; i < parking.length; i++) { | |
console.log(`Auto: ${parking[i]}, Puesto ${i}`); | |
} | |
console.log(`----------------------------`) | |
} | |
parking.push("ROJO", "GRIS", "AZUL", "AMARILLO", "VERDE"); | |
actualizar(); | |
parking.push("BLANCO"); | |
actualizar(); | |
parking[parking.indexOf("AZUL")] = "NEGRO"; | |
actualizar(); | |
parking.shift(); | |
actualizar(); | |
parking.pop(); | |
actualizar(); | |
for (let i = 0; i < parking.length; i++) { | |
if (parking[i] === "AMARILLO") { | |
console.log(`El Auto AMARILLO esta en el puesto ${i}`); | |
} | |
} | |
console.log(`----------------------------`) | |
function buscarAuto(auto) { | |
auto = prompt(`Ingrese el color del auto que desea buscar: `).toUpperCase(); | |
let encontrado = false; | |
let posicion = -1 | |
for (let i = 0; i < parking.length; i++) { | |
if (parking[i] === auto) { | |
encontrado = true; | |
posicion = i | |
break; | |
} | |
} | |
if (encontrado === true) | |
console.log(`El auto ${auto} fue encontrado en la posicion ${posicion}.`); | |
else | |
console.log(`El auto ${auto} no fue encontrado.`); | |
} | |
buscarAuto(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment