Unions and Narrowing 29 exercises
Problem

Reusable Type Guards

Consider the following code:

const joinNames = (value: unknown) => {
  if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
    return value.join(" ");
  }


  throw new Error("Parsing error!");
};


const createSections = (value: unknown) => {
  if (Array.i
Loading exercise

Transcript

no