3 ms·
Maybe I’m misunderstanding the problem but any reason why you can’t just call .map on the input array and if el.name === John -> el.hobby[knitting] = true, the
by LecroJS 5y ago
Maybe I’m misunderstanding the problem but any reason why you can’t just call .map on the input array and if el.name === John -> el.hobby[knitting] = true, then return el regardless?
- adamredwoods 5y agoYou could if the object was a known structure, but I needed a function that could be a utility for any object (some were quite large), something like: const newobj = insertIntoObject( obj, ["name:John", "hobby:*"], newdata )