Skip to content

Commit

Permalink
Merge pull request #498 from HanifAlgamar/main
Browse files Browse the repository at this point in the history
Game Suit Jawa.js
  • Loading branch information
kokonior authored Oct 29, 2022
2 parents d48d8bc + 0462cb1 commit 5bd9aaa
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Game Suit Jawa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var tanya = true;
while(tanya){

// pilihan player
var p = prompt('Pilih : gajah, semut, orang');

// pilihan komputer
// membangkitkan bilangan random
var com = Math.random();

if (com < 0.34){
com = 'gajah';
} else if (com >= 0.34 && com < 0.67){
com = 'semut';
} else {
com = 'orang'
}

//rules
var hasil = '';
if (p == com ){
hasil = 'SERI';
} else if (p == 'gajah'){
hasil = (com == 'orang') ? 'MENANG' : 'KALAH';
} else if (p == 'orang'){
hasil = (com == 'gajah') ? 'KALAH' : 'MENANG';
} else if (p == 'semut'){
hasil = (com == 'orang') ? 'KALAH' : 'MENANG';
} else {
hasil = 'Pilihan Yang Anda Masukkan Salah!!'
}

//hasil
alert('Anda Memilih: '+p+' Dan Komputer Memilih: ' +com+'\nMaka Hasilnya : Kamu '+hasil);

tanya = confirm('Ingin Bermain Lagi?')
}

alert('Terima Kasih Sudah Bermain');

0 comments on commit 5bd9aaa

Please sign in to comment.