💻 Mission 4

B1 · 15 min

Explain What Your Code Does

I can walk a teammate through a function step by step: what it takes, what it does and what it returns.
You opened a pull request in the orders service. Before Alex reviews it, he asks you to walk him through one small function.
orders/service.ts
async function getOrder(id: string) {
const order = await db.orders.findById(id);
if (!order) {
throw new NotFoundError('Order not found');
}
return order;
}
Read it from top to bottom: look up the order, handle the missing order, return the order. You will explain it in the same three steps.

Your mission

Explain getOrder step by step: what it takes, what it checks and what it returns.

Keep learning

Explain What Your Code Does | Sunny Academy