function User (firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
let date = new Date();
this.regDate = date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
}
function UserList (User) {
this.users = [];
this.addUser = function(User){
this.users.push(User);
}
this.getAllUsers = function(){
for (let eachUser of this.users) {
console.log(eachUser);
}
}
}
arr = new UserList;
while(true){
newUser = prompt('Введите имя и фамилию')
if (newUser != null) {
userName = newUser.replace(/\s+/g, ' ').trim().split(' ', 2);
reg = new User(userName[0], userName[1]);
arr.addUser(reg);
}
if (newUser === null) {
arr.getAllUsers();
break;
}
// if (newUser === '' || User.lastName === undefined) {
// alert('Вы не ввели данные!')
// continue;
// }
}