Question: in Java script: Array / Function: Rolling Die Simulation See the sample code with comments. Copy the sample code to your solution. Complete the requirements

in Java script: Array/Function: Rolling Die Simulation
See the sample code with comments.
Copy the sample code to your solution. Complete the requirements in the code template.
Overview
Simulate 1200,2400, or 3600 rolls (number of rolls chosen randomly) of a die and display statistics.
High Leve Tasks
Your code will perform the following tasks:
Populate an array simulating 1200,2400, or 3600 rolls
Create a function that returns the number of times a roll occurred
Input: A digit between 16
Return: A single number. Count the number of times that the digit was rolled
Display output
A simple header
Result statistics (see output and requirements below)
Output
Your numbers will vary as the results are random
Output Format Requirements
A header with your last name and number of rolls in the simulation
Details for each outcome (Actual and expected occurrences and relative frequencies).
Round relative frequency to 3 digits after the decimal
Use the format below.
q2Ver1Output.png
Code Template (Copy this to VS Code and complete the requirements)
// Simulate rolling a die
// Array to store result of each roll
const roll =[];
// Write code to populate the array with the outcome of the rolls.
// Determine Number of rolls - A random number of rolls (1200,2400, or 3600)
// HINT: Generate a random number between 1-3 and multiply it by 1200
//
// Populate the array (use a loop):
// For each roll, generate a random number between 1-6 and add it to the array.
//
// When complete, you will have an array of 1200,2400, or 3600 elements.
// Each element will have a value between 1-6
///// YOUR CODE HERE ///
// Function - Return the number of occurrences of a roll
// Write a function per the following requirements:
// Input: A digit between 1-6(assume valid input)
// Return: A single number. Count the number of occurrences of the digit in the roll[] array
//
// No other tasks are performed by the function.
// Failure to meet these requirements, even if the output is correct, will
// result in an incorrect solution
//
// HINT
// Many ways to do this, one is to loop through the array counting the number of occurrences
//
// OTHER/MISC/OPTIONAL
// The rolls array is global; However, if you want to make your function more generic,
// you may use it as an input parameter.
///// YOUR CODE HERE ///
// Display the results to the console
//
// Generate a header as follows:
// YourLastName Rolling Die Simulation Statistics - XXXX Rolls
// Note: XXXX will be either 1200,2400, or 3600
// e.g. Asher's Rolling Die Simulation Statistics -2400 Rolls
///// YOUR CODE HERE ///
// Write a loop to display the statistics for each possible outcome
// Counts - Actual and Expected. Relative frequency - Actual and expected
// See requirements document for output format.
//
// Note:
// Counts
// Actual - Use the function you created to compute the count of an outcome
// Expected - Total rolls /6
// Relative frequency
// Actual - Actual count (from your function)/ total number of rolls
// Expected -1/6.
//
///// YOUR CODE HERE ///

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!