What does this contract-focused example print?

from Code prompt vocabulary
Node 24 beginner 3 min

What does this contract-focused example print?

JavaScript
function formatShipmentId(prefix, sequence) {
  if (!/^[A-Z]{2,4}$/.test(prefix)) {
    throw new TypeError("invalid prefix");
  }
  return `${prefix}-${String(sequence).padStart(6, "0")}`;
}

console.log(formatShipmentId("EU", 42));
try {
  console.log(formatShipmentId("eu", 42));
} catch (error) {
  console.log(error.name);
}
Open in playground
Report an error