Skip to content

Instantly share code, notes, and snippets.

@midsonlajeanty
Last active October 29, 2022 21:07
Show Gist options
  • Save midsonlajeanty/171f28b002717ebb5a47ae2ca54ddc8b to your computer and use it in GitHub Desktop.
Save midsonlajeanty/171f28b002717ebb5a47ae2ca54ddc8b to your computer and use it in GitHub Desktop.
Woch, Papye, Sizo ...
const CHOICES = ['W', 'P', 'S']
const WIN_CHOICES = ['PW', 'SP', 'WS']
let wantToContinue = true
let ordi_choice
let ordi_score = 0
let user_choice
let user_score = 0
while(wantToContinue){
ordi_choice = CHOICES[Math.floor(Math.random() * CHOICES.length)]
do{
user_choice = prompt("Antre Chwa w la : ")
user_choice = user_choice.toUpperCase()
if(!CHOICES.includes(user_choice))
alert("Ou fe yon move chwa !\nOu ka Chwazi [W], [P] oubyen [S]!\nReeseye!")
} while (
user_choice === null ||
user_choice === undefined ||
!CHOICES.includes(user_choice)
)
if(user_choice === ordi_choice){
alert("Menm CHWA ... Pesonn pa genyen")
}else{
const result = `${user_choice}${ordi_choice}`
console.log(result)
if(WIN_CHOICES.includes(result)){
user_score += 50
ordi_score -= (ordi_score != 0 ? 50 : 0)
alert("Bravo, Ou GENYEN !!!")
}else{
ordi_score += 50
user_score -= (user_score != 0 ? 50 : 0)
alert("Bof, Ou PEDI !!!")
}
alert(`Ou genyen : ${user_score} Pwen.\nOdinate a genyen : ${ordi_score} pwen.`)
}
const cont = prompt("Ou vle kontinye ? [Peze (N) pou di non]").toUpperCase()
if(cont === "N"){
wantToContinue = false
alert("Mesi paske w te jwe avek nou !!!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment