Skip to content
Quiz · Narrowing · lesson 2 of 12

Quiz — the type after return

Which type does v have on the line return v.trim();?

TypeScript
function pad(v: string | number) {
    if (typeof v === "number") {
        return v.toFixed(2);
    }
    return v.trim();
}