-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment17.js
29 lines (29 loc) · 1.01 KB
/
assignment17.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
"use strict";
let guest = ['hamid', 'ahmed', 'asim'];
let randomNum = Math.floor(Math.random() * 2);
console.log(`sorry ${guest[randomNum]} could'nt get to the dinner`);
guest[randomNum] = 'jason';
for (let i = 0; i < guest.length; i++) {
console.log(`can you come to the dinner ${guest[i]}`);
}
;
console.log("hello guest we just found a bigger dinning table ");
guest.unshift("Kamran");
guest.splice(2, 0, "Iftikhar");
guest.push("Babar");
for (let i = 0; i < guest.length; i++) {
console.log(`you guys are also invited to the dinner party ${guest[i]} `);
}
console.log(" Sorry i can only invite two people for dinner");
for (let c = 0; c < guest.length + 1; c++) {
let removedGuest = guest[guest.length - 1];
console.log(` Sorry ${removedGuest} i could'nt invite you to the dinner `);
guest.pop();
}
for (let c = 0; c < guest.length; c++) {
console.log(` You guys are still Invites : ${guest[c]}`);
}
for (let c = 0; c <= guest.length; c++) {
guest.pop();
console.log(`Empty List ${guest}`);
}