forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mouredev#4194 from Cesar-Ch/add-cesar-solutions
Reto mouredev#25 - Javascript
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Retos/Reto #25 - EL CÓDIGO KONAMI [Media]/javascript/cesar-ch.js
This file contains 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
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 | ||
} | ||
|
||
}); |