Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Simple Javascripts game

Hey everyone,

I have to make a simple Javascript game for a school assignment. I tried a lot of stuff already, but I can't get it to work.

My idea is a russian roulette game, where your able to chose the amount of bullets you want to put in the revolver. The higher the amount, how more chance you have to lose offcourse. It is kind of the idea of this version I found: http://www.javascriptkit.com/script/...roulette.shtml
The only problem is, that I'm not allowed to use it in html. I have to use console.log instead of the picture. A seperated window to be more precise.

Anyone that can help me making this game? I don't think it's very hard but I just started Javascripts and I don't understand anything of it. Especially making the computer chose a random number between 1-6 to decide whether you are dead or not.

Houstyn

• Please have look at forum rule #1.5.

This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for homework), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

As a boon I will show you how to generate a random number from 1-6:-

Code:
```var randy = Math.floor(Math.random() * 6 +1);  // generates 1-6 randomly
alert (randy); // to inspect the result```
Quizmaster: The Garden of Gethsemane in Jerusalem is at the foot of the Mount of ... what?
Contestant: Everest.

• in 64 seconds:
Code:
```alert(
[0,1,2,3,4,5].map(function(a){return a<this},prompt("how many bullets",1))
[  Math.floor(Math.random() * 6 +1) ] ?
"Whew, you should stop while you're ahead!"
)```

• Of course you should never use either prompt or alert in a script intended for use in the 21st century. Most browsers now assume that those will only be used for debugging. If I were to run rnd_me's script then I could set the checkbox in the prompt instead of typing in a number and bang JavaScript's dead for this page and none of the rest of the script gets to run.

•