Is there a way to shorten or refactor this longVersion() function below? Any ideas is appreciated. Thanks!
https://replit.com/talk/share/convert-obj-to-ary/137799
const person = {
name: 'Juan De la Cruz',
job: 'Programmer',
}
function longVersion(person) {
let aryPerson = []
if (Array.isArray(person) && person.length > 0) {
aryPerson = person
} else {
aryPerson.push(person)
}
return aryPerson
}
const result = longVersion(person)
console.log('longVersion:', result)
//output: longVersion: [ { name: 'Juan De la Cruz', job: 'Programmer' } ]