JSFiddle - React, Tailwind, and code Playground
by TheNix
JavaScript
const strings = ['foo', 'bar', 'baz'];
const doDispatch = () => {
// destructures strings into named variables
const [beneficiary1, beneficiary2, beneficiary3] = strings;
// return object with key/value pairs
return {
beneficiary1,
beneficiary2,
beneficiary3,
}
}
const hello = [
{
name: 'bravo'
},
{
name: 'charlie'
},
{
name: 'alpha'
}
]
const sorted = hello.sort((a, b) => a.name.localeCompare(b.name))
console.log(sorted)
//console.log(doDispatch())