Question: 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

Can someone help me come up with a JavaScipt code: The frequency

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!