-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq17.ts
33 lines (20 loc) · 828 Bytes
/
q17.ts
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
// name array
let guestarray:string[] = ["farrukh","yasir","nabeel"];
// can not make dinner
let canNotAttend:string = "nabeel";
// invite new guest
let newGuest :string = "hassan";
guestarray[guestarray.indexOf(canNotAttend)]=newGuest;
// send message
guestarray.unshift("faizan");
let middleguest:string = "salman";
let middleindex = guestarray.length/2;
guestarray.splice(middleindex,0,middleguest);
guestarray.push("raheel");
console.log(guestarray);
console.log("we can invite only two people for dinner!");
while(guestarray.length>2){let removeguest =guestarray.pop();console.log(`sorry ${removeguest} we cant invite you to dinner`);}
guestarray.map((item)=> console.log(`${item} you are still invited to dinner`));
guestarray.pop();
guestarray.pop();
console.log(guestarray);