TypeScript · Junior · Question 54 of 75

What is the type of users.find((u) => u.id === id) if users: User[]?

Explanation

find may not find anything, so you must handle undefined before using the result.

Further reading

Problem with a question

TypeScript · Junior · question 54

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz