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