-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
54 lines (43 loc) · 1.3 KB
/
main.js
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
var names_of_people = [];
function submit()
{
var GuestName = document.getElementById("name1").value;
// use the push function as - names_of_people.push(GuestName);
names_of_people.push(GuestName);
console.log(GuestName);
console.log(names_of_people);
var lenght_of_name = names_of_people.length;
console.log(lenght_of_name);
document.getElementById("name1").value="";
document.getElementById("display_name").innerHTML="The names are : " + names_of_people.toString() +".";
}
function show()
{
var i= names_of_people.join("<br>");
console.log(names_of_people);
document.getElementById("p1").innerHTML=i.toString();
document.getElementById("sort_button").style.display="block";
}
function sorting()
{
names_of_people.sort();
var i= names_of_people.join("<br>");
console.log(names_of_people);
document.getElementById("sorted").innerHTML=i.toString();
}
function searching()
{
var s = document.getElementById("s1").value;
document.getElementById("s1").value="";
s.toString();
var found=0;
var j;
for(j=0; j<=names_of_people.length; j++)
{
if(s==names_of_people[j]){
found++;
}
}
document.getElementById("p2").innerHTML="Name is found "+found+" times .";
console.log("found name "+found+" time/s");
}