Last active
January 16, 2024 20:44
-
-
Save didierbrun/938ffd6536e656faf7f93260d2d31159 to your computer and use it in GitHub Desktop.
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
class Explique {} | |
Explique.stack = [] | |
Explique.on = false | |
Explique.delay = (time) => new Promise(resolve => setTimeout(resolve, time)) | |
Explique.phrase = (phrase, duration = 0) => { | |
Explique.stack.push({phrase, duration}) | |
if (!Explique.on){ | |
Explique.on = true | |
Explique.disNext() | |
} | |
} | |
Explique.disNext = async () => { | |
const { phrase, duration } = Explique.stack.shift() | |
console.log(phrase) | |
await Explique.delay(duration) | |
if (Explique.stack.length > 0){ | |
Explique.disNext() | |
} else { | |
Explique.on = false | |
} | |
} | |
let sexe = "p" | |
let age = 16 | |
let qi = 131 | |
if (sexe == "h") { | |
Explique.phrase("On a donc à faire à un homme...", 1000) | |
if (age < 18){ | |
Explique.phrase("C'est même un jeune homme...", 1000) | |
} | |
if (qi > 130){ | |
Explique.phrase("Qui a un gros QI !", 1000) | |
Explique.phrase("Un très gros QI !!!", 1000) | |
} | |
} else if (sexe == "f"){ | |
Explique.phrase("C'est bien une femme....", 1000) | |
if (age < 18){ | |
Explique.phrase("Ou plustôt une jeune femme...", 1000) | |
} | |
if (qi > 130){ | |
Explique.phrase("Qui a un QI remarquable !", 1000) | |
} | |
} else { | |
Explique.phrase("Alors là.... je ne sais pas.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment