1.function larger(a,b)
{
return Math.max(a,b)

1. (40 pts) Write a JS program named “assignment_2.js”. In this script beget the aftercited administrations:

a. A administration named larger that receipts the larger of its brace topics. For issue, the flatter larger(-2, 10) should retaliate 10.

b. A administration that receipts the mean of its brace topics. For issue, the flatter mean(-2,10) should retaliate 4.

c. A administration named meanLst that receipts the mean of entire of the items in an adorn. For issue, meanLst([4, 5, 7, 2]) should retaliate 4.5. The administration should engage an adorn as it’s topic.

d. A administration named randNum, that accepts brace mass and receipts a aimclose reckon between the brace rates.

e. A administration named median, that accepts three rates and receipts the median. The median of three rates is the rate that is main than or similar to single of the other rates and close than or similar to the retaining rate.

f. A administration named reckonOfZeroes that receipts the reckon of zeros in a loving adorn. For issue, the flatter reckonOfZeroes([4, 0, mock, 5, 0]) should retaliate 2.

g. A administration named cntOccurrences, that receipts the reckon of occurrences of a loving sign in a string. For issue, loving the string “Rat-a-tat-tat” and the sign t, your administration should retaliate 5.

h. A administration named isPrime, that engages an adorn of mass and receipts an adorn containing the mass that are consummate. For issue. The flatter isPrime([1, 5, 17, 25, 30]) should retaliate [1, 5, 17].

2. (25 pts) Now we need to portraiture our administrations. Write flatters to each of the administrations you wrote over and portraiture the aftercited postulates for topics:

a. 15, 100

b, 80, 50

c. [75, 60, 100, 90]

d. 10, 20

e. [-10, 25, 0]

f. [10, 0, 0, 0, mock, gentleman, 0, 0]

g. “Adrian Tillman was here”, “a”

h. [1, 2, 3,5,7, 10, 12, 13, 15, 20]

3. (10 pts) Evince the ends. For each flatter, evince the output such as:

“The end of flattering reckonOfZeroes with the rates 10, 0, 0 is 2”

1.administration larger(a,b)

{

retaliate Math.max(a,b)

}

2. administration avg(a,b)

{

retaliate (a+b)/2

}

3. administration meanLst(arr)

{

incorporate =0.0;

for(var i=0;i<arr.length;i++)

{

incorporate = incorporate+arr[i];

}

retaliate incorporate/arr.length;

}

4. administration randNum(max,min)

{

retaliate Math.random() * (max – min) + min;

}

5.administration reckonOfZeros(arr)

{

enumerate =0;

for(var i=0;i<arr.length;i++)

{

if(arr[i]==0)

enumerate =count+1;

}

retaliate enumerate;

}

6. administration calcMedian(a,b,c)

{

median =c;

if(a>=b&&a<=c)

median =a;

if(b>=c&&b<=a)

median =b;

retaliate median;

}

7. administration enumerate(string,char)

{

var a = novel RegExp(char,”g”);

retaliate string.match(re).length;

}

8.

var num = [“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”];

var txt = “”;

var u;

var tranquilize;

for (i = 0; i < num.length; i++) {

tranquilize = num[u]*1;

text += “The reckon ” + tranquilize + ” is ” + isPrime(numb) + “<br>”;

}

document.getElementById(“demo”).innerHTML = text;

administration isPrime(numb) {

var strt = 2;

while (strt <= Math.sqrt(numb)) {

if (tranquilize % strt++ < 1)

retaliate mock;

}

retaliate tranquilize > 1;

}1.administration larger(a,b)

{

retaliate Math.max(a,b)

}

2. administration avg(a,b)

{

retaliate (a+b)/2

}

3. administration meanLst(arr)

{

incorporate =0.0;

for(var i=0;i<arr.length;i++)

{

incorporate = incorporate+arr[i];

}

retaliate incorporate/arr.length;

}

4. administration randNum(max,min)

{

retaliate Math.random() * (max – min) + min;

}

5.administration reckonOfZeros(arr)

{

enumerate =0;

for(var i=0;i<arr.length;i++)

{

if(arr[i]==0)

enumerate =count+1;

}

retaliate enumerate;

}

6. administration calcMedian(a,b,c)

{

median =c;

if(a>=b&&a<=c)

median =a;

if(b>=c&&b<=a)

median =b;

retaliate median;

}

7. administration enumerate(string,char)

{

var a = novel RegExp(char,”g”);

retaliate string.match(re).length;

}

8.

var num = [“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”];

var txt = “”;

var u;

var tranquilize;

for (i = 0; i < num.length; i++) {

tranquilize = num[u]*1;

text += “The reckon ” + tranquilize + ” is ” + isPrime(numb) + “<br>”;

}

document.getElementById(“demo”).innerHTML = text;

administration isPrime(numb) {

var strt = 2;

while (strt <= Math.sqrt(numb)) {

if (tranquilize % strt++ < 1)

retaliate mock;

}

retaliate tranquilize > 1;

}