-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq30.ts
More file actions
30 lines (23 loc) · 1.16 KB
/
q30.ts
File metadata and controls
30 lines (23 loc) · 1.16 KB
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
// Hello Admin: Make a array of five or more usernames, including the name 'admin'. Imagine you are writing code that will print a greeting to each user after they log in to a website. Loop through the array, and print a greeting to each user:
// • If the username is 'admin', print a special greeting, such as Hello admin, would you like to see a status report?
// • Otherwise, print a generic greeting, such as Hello Eric, thank you for logging in again.
export default function q30() {
let usernames: string[] = ['admin', 'Alice', 'Bob', 'Charlie', 'David', 'Eve'];
for (let i = 0; i < usernames.length; i++) {
let username: string = 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.`);
}
}
console.log("\n");
usernames.forEach(function (username: string) {
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.`);
}
});
}
q30();