Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me come up with a JavaScipt code: The frequency of each possible roll (2 to 12 inclusive) must be updated, and the

Can someone help me come up with a JavaScipt code:

  1. The frequency of each possible roll (2 to 12 inclusive) must be updated, and the frequency as a percentage of the total number of accumulated rolls must be updated.

This is my current code to roll dice

Help will be very appreciated been stuck for over a week

image text in transcribed

let count = 0; function throwdice() { let rand1 = Math.ceil( x: Math.random() *6); let rand2 = Math.ceil( x: Math.random() *6); let result = rand2 + rand1; //change the image show by string concatenation document.getElementById( elementld: "image1").src = "images/dice" + rand1 + ".png"; document.getElementById( elementid: "image2").src = "images/dice" + rand2 + ".png"; //set alt image let sideAlt = ["roll:1", "roll:2", "roll:3", "roll:4", "roll:5", "roll:6"] document.getElementById( elementld: "image1").alt = sideAlt[rand1-1] document.getElementById( elementld: "image2").alt = sideAlt[rand2-1] arrayResult[indexPos] = rand1 + rand2; indexPos++; addToArray(); die Interval(); document.getElementById( elementld: "pRolled").innerHTML = "You rolled " + result; count++; document.getElementById( elementld: "pTotalRolls").innerHTML = "My statistics for a total of rolls:" + count; } let count = 0; function throwdice() { let rand1 = Math.ceil( x: Math.random() *6); let rand2 = Math.ceil( x: Math.random() *6); let result = rand2 + rand1; //change the image show by string concatenation document.getElementById( elementld: "image1").src = "images/dice" + rand1 + ".png"; document.getElementById( elementid: "image2").src = "images/dice" + rand2 + ".png"; //set alt image let sideAlt = ["roll:1", "roll:2", "roll:3", "roll:4", "roll:5", "roll:6"] document.getElementById( elementld: "image1").alt = sideAlt[rand1-1] document.getElementById( elementld: "image2").alt = sideAlt[rand2-1] arrayResult[indexPos] = rand1 + rand2; indexPos++; addToArray(); die Interval(); document.getElementById( elementld: "pRolled").innerHTML = "You rolled " + result; count++; document.getElementById( elementld: "pTotalRolls").innerHTML = "My statistics for a total of rolls:" + count; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

How is the cash flow statement dated and why?

Answered: 1 week ago

Question

=+employee to take on the international assignment?

Answered: 1 week ago

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago