|
|
|
|
|
by disillusionist
426 days ago
|
|
you can do this rather easily by returning an object rather than a primitive. if you're using a language like TypeScript, destructuring the resulting returned object is rather trivial and (in my opinion) delightful to read.
eg function combineNames({ first, last }) {
const fullName = `${first} ${last}`;
return { fullName };
}
const { fullName } = combineNames({first: 'John', last: 'Doe' });
|
|