-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion31.ts
37 lines (32 loc) · 1.05 KB
/
question31.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
34
35
36
37
// usernames
let usernames: string[] = ['areeba', 'bisma', 'rabia', 'haleema', 'sumbul'];
// Check if the list of users is not empty
if (usernames.length > 0) {
// greetings
for (let i = 0; i < usernames.length; i++) {
const username = usernames[i];
if (username === 'admin') {
console.log("Hello admin, would you like to see a status report?");
} else {
console.log(`Hello ${username}, thank you for logging in again.`);
}
}
} else {
console.log("We need to grow our user base.");
}
// Remove all usernames
usernames = [];
// Check if the list of users is not empty
if (usernames.length > 0) {
// print greetings (this won't be for an empty list)
for (let i = 0; i < usernames.length; i++) {
const username = usernames[i];
if (username === 'admin') {
console.log("Hello admin, would you like to see a status report?");
} else {
console.log(`Hello ${username}, thank you for logging in again.`);
}
}
} else {
console.log("We need to grow our user base.");
}