Skip to content

Commit

Permalink
Merge pull request mouredev#4194 from Cesar-Ch/add-cesar-solutions
Browse files Browse the repository at this point in the history
Reto mouredev#25 - Javascript
  • Loading branch information
kontroldev authored Jul 19, 2023
2 parents b18c073 + 14d28d6 commit 90c58d8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Retos/Reto #25 - EL CÓDIGO KONAMI [Media]/javascript/cesar-ch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Crea un programa que detecte cuando el famoso "Código Konami" se ha introducido correctamente
* desde el teclado. Si sucede esto, debe notificarse mostrando un mensaje en la terminal.
*/

const konamiCode = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "KeyB", "KeyA"];
let i = 0

document.addEventListener("keydown", (e) => {
e.code === konamiCode[i] ? i++ : i = 0;
if (i === konamiCode.length) {
console.log("🎉 GANASTE 🎉")
i = 0
}

});

0 comments on commit 90c58d8

Please sign in to comment.