-
Notifications
You must be signed in to change notification settings - Fork 0
/
task17.js
42 lines (35 loc) · 961 Bytes
/
task17.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
const guest=["Family","Friends","Neighbor"];
for(var i=0;i<guest.length;i++)
{
console.log("Hi "+guest[i]+", \n\tyou all are invited to a dinner that is arranged by me at 7pm on this upcoming sunday.\nTHANKYOU. " );
}
var g4="Fasih";
var g5="Ali";
//start me dalnay k liye
guest.unshift(g4);
guest.push(g5);
//end pe dalne k liye
for(var i=0;i<guest.length;i++)
{
console.log(" "+guest[i]+" " );
}
console.log(" You can invite only 2 people. table haven't arrived yet :( " );
for(var i=0;i!=guest.length && guest.length!=2;i++)
{
var popped = guest.pop();
console.log("sorry you cannot invite "+ popped+ " them to dinner <br>");
}
for(var i=0;i<guest.length;i++)
{
console.log(" "+guest[i]+" you are still invited. " );
}
//making it empty
for(var i=0;i!=guest.length && guest.length!=0;)
{
guest.pop();
}
//remaining guests
if(0==guest.length)
{
console.log(" List is empty. ");
}