Tiny issue:
Usernames are always available for me using this example as a found user is returned to nowhere?
export function getUserByUsername(username: string) {
users.forEach((user) => {
if (user.username === username) {
return user; // returns to nowhere as far as I can see
}
});
return null;
}
The following change fixes it for me:
export function getUserByUsername(username: string): User | null {
let foundUser = null;
users.forEach((user) => {
if (user.username === username) {
foundUser = user;
}
});
return foundUser;
}