Question: using JavaScript. Use the Following functions create calls to each of the functions then display the results. use the following data for arguments: e. [-10,
using JavaScript. Use the Following functions create calls to each of the functions then display the results. use the following data for arguments:
e. [-10, 25, 0]
f. [10, 0, 0, 0, false, true, 0, 0]
g. "Adrian Tillman was here", "a"
h. [1, 2, 3,5,7, 10, 12, 13, 15, 20]
Functions:
E:
def median(lst):
sortedLst = sorted(lst)
lstLen = len(lst)
index = (lstLen - 1) // 2
if (lstLen % 2):
return sortedLst[index]
else:
return (sortedLst[index] + sortedLst[index + 1])/2.0
F:
def numberOfZeroes(lst):
count=0
for val in lst:
if val==0:
count+=1
return count
G:
def cntOccurrences(string,char):
count=0
for ch in string:
if ch==char:
count+=1
return count
H:
def isPrime(lst):
prime_lst=[]
for val in lst:
if val > 1:
for i in range(2,val):
if (val % i) == 0:
break
else:
if val not in prime_lst:
prime_lst.append(val)
return prime_lstreturn Math.floor(Math.random() * (max - min + 1)) + min;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
