Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. [20 pts] 111/p5/Dice.js . Download Dice.js to your 111/p5/folder. A) Complete the rollNDice() method. It should roll N dice and return an array representing
3. [20 pts] 111/p5/Dice.js.
Download Dice.js to your 111/p5/folder.
A) Complete the rollNDice() method. It should roll N dice and return an array representing the rolls:
Dice.rollNDice(6) => [x,x,x,x,x,x] Dice.rollNDice(3) => [x,x,x]
B) Complete the sumNDice() method:
Dice.sumNDice([1,2,3,4]) => 10 Dice.sumNDice([2,3]) => 5 Dice.sumNDice([]) => 0
C) Complete the maxRoll() function: Dice.maxRoll([1,2,3,4]) => 4
D) Complete the isAllOfAKind() function:
Dice.isAllOfAKind([2,2,2,2]) => true Dice.isAllOfAKind([2,2,2,1]) => false
var Dice sides 6, current DiceRollsArray: default Image Path: ''images /3d dice. png", rollDie: function return Math. floor (Math. random this. sides) 1; rollNDice: function n sumNDice: function diceAry max Roll: function (diceAry) t is AllOfAKind: function (diceAry) get Dice Image Path: function (p) return images/red dice p ".png
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started