-
Notifications
You must be signed in to change notification settings - Fork 0
/
day6_JS_questions.html
66 lines (52 loc) · 1.48 KB
/
day6_JS_questions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<!--ALL ARRAY ASSIGNMENT QUESTIONS-->
<script>
function is_array(arr) {
return Array.isArray(arr);
}
function array_clone(arr) {
var b=arr.valueOf()
return b;
}
function firstN(arr,n=0){
var len=arr.length;
if(n<0||len===0){
return [];
}
else if(n>len){
return arr ;
}
else {
arr.slice(0,n);
}
}
function Array_to_string(a) {
return a.toString();
}
function frequancy() {
var a = [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
var maxfre=0;
var item=null;
for (i = 0; i < a.length; i++) {
var count=1;
for (j = i + 1; j < a.length; j++) {
if (a[i] === a[j])
{
count++;
}
}
if (maxfre<count) {
maxfre=count;
item=a[i];
}
}
console.log(item+"is reapting for max times: "+maxfre)
}
</script><body></body></html>