← #46 Log an array to the Console
#47

Format a list

Topics: JavaScript

We can take the advantage of the Intl.ListFormat object to format a list for a given locale:

const people = ['Foo', 'Bar', 'Fuzz'];

new Intl.ListFormat('en', { type: 'conjunction' }).format(people);
// 'Foo, Bar, and Fuzz'

new Intl.ListFormat('en-GB', { type: 'disjunction' }).format(people);
// 'Foo, Bar, or Fuzz'
Fix a typo or suggest an improvement
#48 Pretty format JSON