I have an array like the following: var arr = ['one', 'two', ['three', 'four']];
While trying to return each element by using the arrow function, it returns undefined
as the third element, instead of the elements values. I've attempted to restructure it, but none of then return all the elements of both arrays. I could use a for loop, do the logic to push each element, but I want to understand and learn how to use arrow functions for cases like this.
arr.map(e => {
if(typeof(e) == "object"){
e.map(t => t)
} else{ return e; }
})
Will really appreciate some clarification in this matter. The expected result is an array like the following: ['one', 'two', 'three', 'four'].