Question: Write a program as follow: a. Create a function that takes a parameter i. The function generates a random whole number between 1 and 10

Write a program as follow: a. Create a function that takes a parameter i. The function generates a random whole number between 1 and 10 and then raise i to the power of the generated whole number(HINT: Math.pow()). The function then prints i, the random number and the result of the power. b. Pass the above function to the higher order function repeat(n, action) shown below using 6 as n. The function from step a. should be able to print the calculation result for 5 times as shown in the example output. You cannot modify the repeat function in any way.

0 points if not using the repeat function to perform the task 10 points off if the repeat function is modified

function repeat(n, action) { for (let i = 0; i < n; i++) { action(i); } }

Show its output as well

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!