[Solved] How do I use es6 syntax with split? [duplicate]


.split results in an array output but you’re destructuring it as if it were an object.

Do

const [city, country] = 'los gatos, california'.split(/\s*,\s*/);
console.log(city);
console.log(country);

You destructure by using array destructuring ([..]) instead of object ({..})

solved How do I use es6 syntax with split? [duplicate]