- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.html
More file actions
Latest commit
82 lines (68 loc) · 2.66 KB
/
Copy patharray.html
File metadata and controls
82 lines (68 loc) · 2.66 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>demo</title>
</head>
<body>
<inputtype="text" name="" value="" id="numb" />
<inputtype="submit" name="" value="Submit" onclick="getValue()" />
<script>
/*var x = [1,2,3,4,5,6,7,8];
var n = 2;
if(n == 2){
document.write('yes')
}else{
document.write('No')
}*/
document.write('<br/><br/>'+'<b>Q1: Number Exist or not</b> [1,2,3,4,5,6,7,8]');
functiongetValue(){
vara=document.getElementById('numb').value;
varb=0;
vary=[1,2,3,4,5,6,7,8];
for(i=0;i<y.length;i++){
if(a==y[i]){
b++;
}
}
if(b>0){
document.write('Number Exist in Array');
}else{
document.write('Number does not Exist in Array');
}
}
document.write('<br/><br/>'+'<b>Q2: Highest Vlue / Lowest value</b> [11,28,13,54,25,16,67,78]'+'<br/><br/>');
vararr=[11,28,13,54,25,16,67,78];
varhv=0;
varlv='';
for(d=0;d<arr.length;d++){
if(hv<arr[d]){
hv=arr[d];
}
}
document.write(hv+'<br/>');
for(e=0;e<arr.length;e++){
if(lv>arr[e]||lv==''){
lv=arr[e];
}
}
document.write(lv+'<br/>');
</script>
<script>
document.write('<br/><br/>'+'<b>Q3: Sort / Reverse</b> [Banana, Apple, Flower, Kela, Lotus, Rose]'+'<br/><br/>');
varsrt=['Banana','Apple','Flower','Kela','Lotus','Rose'];
varrslt=srt.sort();
document.write(rslt+'<br/>');
document.write(rslt.reverse());
document.write('<br/><br/>'+'<b>Q4: Sort / Reverse</b> [25, 18, 45, 88, 75, 63, 33, 69, 3, 8, 9, 1]'+'<br/><br/>');
varsrtNum=[25,18,45,88,75,63,33,69,3,8,9,1];
varrsltNum=srtNum.sort(function(a,b){returna-b});
document.write(rsltNum+'<br/>');
varsrtNum2=[25,18,45,88,75,63,33,69,3,8,9,1];
varrsltNum2=srtNum2.sort(function(a,b){returna-b});
document.write(rsltNum2.reverse());
document.write('<br/><br/>'+'<b>Q5: Sort / Reverse with function</b> [25, 18, 45, 88, 75, 63, 33, 69, 3, 8, 9, 1]'+'<br/><br/>');
varsrtNumF=[25,18,45,88,75,63,33,69,3,8,9,1];
</script>
</body>
</html>