CodePark/ questions / The Intl APIs
START PRACTICINGPRACTICE
Frontend question · Internationalization › The Intl APIs

What does this print?

const names = ["Ana", "Ben", "Chloe"];
console.log(new Intl.ListFormat("en-US", { type: "conjunction" }).format(names));
console.log(new Intl.ListFormat("en-GB", { type: "conjunction" }).format(names));
Ana, Ben, and Chloe and Ana, Ben and Chloe

Intl.ListFormat follows each locale's style. US English uses the serial (Oxford) comma before "and", and British English usually doesn't. Other languages use their own word, like "y" in Spanish or "und" in German.

"Twice the same" is the tempting wrong answer. Even two English locales differ, which is why
names.join(", ") plus a hard-coded "and" breaks in translation. type: "disjunction" gives "or" lists.