Hello everyone im trying apply this simple logic but. i get undefined elements in an array. İ know i can do it with filter but i wanna do it this way so whats the solution ? What is the problem i am having ? Thank you in advance!
const newArr = ["abc", 12, 43, 8, 9, 0, 15, 23]
const newww = newArr.map(n => {
(typeof (n) === "string") ? {return n} : {return n.toString}
}
)
The logic in English is: İf the type of n is equals to string return n if not return empty string.
Aucun commentaire:
Enregistrer un commentaire