Hey there,
I could really use some assistance with an issue I've encountered. Whenever I try to click on "cancel" in a prompt, I keep getting this error message: "Cannot read properties of null (reading 'split')".
Basically, all I want is for the loop to terminate when I cancel it in the prompt.
ps.: In case you're wondering, this involves a simple array containing names and surnames that will be displayed using console.log in the future.
function UserList () {
let users = [];
while(true) {
users.push (prompt('Please, enter your name surname?').split(' '));
if (prompt=== null) {
alert('cancel');
}
}
}
let userList = new UserList();