Full Stack Developer | Freelancer | JavaScript | React | Nodejs. https://yogeshchavan.dev/. Book 1:1 @ hiretheauthor.com/myogeshchavan97
Full Stack Developer | Freelancer | JavaScript | React | Nodejs. Loves sharing knowledge through technical articles. Dev.to: https://dev.to/myogeshchavan97 https://linktr.ee/myogeshchavan97
Markdown supported · ⌘↵ to post
This article is so useful, cause I recently had an array with something like arr = [ {name: foo, count:2}, {name2: doe, count:5} ] and I wanted to convert all count values to percentage while maintaining names as they're and get results into a new array, I think the add function and dynamic object trick you have provided here can make it work, I just haven't figured it out. But in all this is awesome, thanks!
Chety
Hey Yogesh Chavan
Good tips thanks. By the way, I can add my two cents to your article.
arr.slice(-1)will return[50]not the value50.const isArray = Object.prototype.toString.call(arr) == "[object Array]"