Question: using JavaScript create the following functions: a. A function called larger that returns the larger of its two arguments. For example, the call larger(-2, 10)

using JavaScript create the following functions:

a. A function called larger that returns the larger of its two arguments. For example, the call larger(-2, 10) should return 4.

b. A function that returns the average of its two arguments. For example, the call average(-2,10) should return 4.

c. A function called averageLst that returns the average of all of the items in an array. For example, averageLst([4, 5, 7, 2]) should return 4.5.

d. A function called randNum, that accepts two numbers and returns a random number between the two values.

e. A function called median, that accepts three values and returns the median. The median of three values is the value that is greater than or equal to one of the other values and less than or equal to the remaining value.

f. A function called numberOfZeroes that returns the number of zeros in a given array. For example, the call numberOfZeroes([4, 0, false, 5, 0]) should return 2.

g. A function called cntOccurrences, that returns the number of occurrences of a given character in a string. For example, given the string "Rat-a-tat-tat" and the character t, your function should return 5.

h. A function called isPrime, that takes an array of numbers and returns an array containing the numbers that are prime. For example. The call isPrime([1, 5, 17, 25, 30]) should return [1, 5, 17].

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!