Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey there, I need help with this, it must be done in javascript 1 2 4 is one of

ID: 3670157 • Letter: H

Question

Hey there, I need help with this, it must be done in javascript

1 2 4 is one of very few dice games not built for gambling. It's a game for any number of players. Two to four is probably best. It's a friendly way to pass some time (2 seconds to maybe 10 minutes per game), since it mostly requires you to keep track of your own progress, and trust others to do the same. It moves quickly, so the more players, the harder to keep track of others' play.

So the assignment is

1.Use arrays to help you build a game of 1 2 4 for one person.

An array named roll can hold the three numbers of each roll.
(For 1 extra point, use a two-dimensional array to keep track of all numbers rolled throughout the game.)

Feel free to use other arrays if you can find a place for them.

2.Follow the rules of the game.

A. Use Math.floor(Math.random) to simulate each roll of the dice (three times for three dice). Store the results in an array.

B.Did you roll 1 2 4? You win! (Congratulations. Play again?) Otherwise:

C. Did you roll 3 of a kind? Time to start over. Otherwise:

D.Compare all the dice and all the combinations to the required point. (Did you get the point you were looking for?)

If you got the point, check to see if you got the next. Repeat.

If you did not get the point, pass play to the next player. (Note that when there's only 1 player, you just pass to yourself.)

E. When you get all the points through 1 2 3 4 5 6 7 6 5 4 3 2 1, you win. Play again?

F. Display every roll, along with results. You can use a table such as the one above, or use your own layout, but for every roll, show

the point,

the numbers revealed on the dice, and

the result.

NOTE that the instructions you to display an entire game, all at once

Explanation / Answer

<p>
    <script>
        var roll = new Array(1);
        document.writeln("Start The Game...<br>");

        function startGame() {
            var n1, n2, n3, count = 0;
            while (true) {
                n1 = Math.floor(Math.random() * (6 - 1 + 1)) + 1;
                n2 = Math.floor(Math.random() * (6 - 1 + 1)) + 1;
                n3 = Math.floor(Math.random() * (6 - 1 + 1)) + 1;
                roll[count] = new Array(3);
                roll[count][0] = n1;
                roll[count][1] = n2;
                roll[count][2] = n3;
                document.writeln("Your dices ..." + roll[count] + "<br>");
                if ((n1 == 1 && n2 == 2 && n3 == 4) ||
                    (n1 == 1 && n2 == 4 && n3 == 2) ||
                    (n1 == 4 && n2 == 1 && n3 == 2) || (n1 == 4 && n2 == 2 && n3 == 1) || (n1 == 2 && n2 == 1 && n3 == 4) || (n1 == 2 && n2 == 4 && n3 == 1)) {
                    document.writeln("You won the game...play again?y or n<br>");

                    document.writeln("<input type='text' name='enter' class='enter' value='' id='lolz'/>");
                    document.writeln("<input type='button' value='click'/>");

                    break;
                } else if (n1 == n2 && n2 == n3) {
                    document.writeln("Try again the Game...<br>");
                }
            }
        }
        startGame();

        function isContinue() {
            lolz = document.getElementById('lolz').value;
            if (lolz === 'y' || lolz === 'Y') {
                startGame();
            } else {
                document.writeln("Thank you for playing....<br>");
            }
        }
    </script>
</p>

http://js.do/code/84106 here you can try yourself.

Could you please explain the D part also I have implemented single player game. You can implement for multip[[layer by the above logic. Let me know if you require more informaiton.