-
Notifications
You must be signed in to change notification settings - Fork 0
/
qno32.js
19 lines (19 loc) · 1.24 KB
/
qno32.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"use strict";
// Qno.32
// Checking Usernames: Do the following to create a program that simulates how websites ensure that everyone has a unique username.
// • Make a list of five or more usernames called current_users.
// • Make another list of five usernames called new_users. Make sure one or two of the new usernames are also in the current_users list.
// • Loop through the new_users list to see if each new username has already been used. If it has, print a message that the person will need to enter a new username. If a username has not been used, print a message saying that the username is available.
// • Make sure your comparison is case insensitive. If 'John' has been used, 'JOHN' should not be accepted.
Object.defineProperty(exports, "__esModule", { value: true });
let current_users = ["Ali", "ayaz", "saba", "Misbah", "Sara"];
let new_users = ["sara", "fayz", "ayaz", "adam", "daniyal"];
new_users.forEach(new_one_user => {
let our_condition = current_users.some(current_one_user => current_one_user.toLowerCase() === new_one_user.toLocaleLowerCase());
if (our_condition) {
console.log(`Sorry ${new_one_user} is already taken !.`);
}
else {
console.log(`${new_one_user} username is available.`);
}
});