New answers tagged


Neither of your solutions handles the type of the replacement correctly. For instance "" replaces foo:333444 with foo:"111222" where I would expect it to result in foo:111222. Further they can handle if the replacement is an array, but not if it is an object due to the use of split(':'). You should use str.indexOf(':') ...


I think I found solution much cleaner and simpler to understand: That solution adjusted to my task const testStr = ''; const testObj = { bar: { baz: { foo: '333444', }, }, }; console.log('[before] =',; // run replaceInObj(testObj, ...


For an interview, this is bad code. It is \$O(n \log n)\$. But it can be done in \$O(n)\$ time. Your code does not show your skills in that direction. Also, many interviewers (justifiably) will be unhappy for using streams. Streams may look cute but at scale like Gmail, they cause performance problems.


Avoid using in header files It looks like the code you have written is in a header file, which is to be included in an actual application that needs to intersect polygons. If you include this file, it also means you pull in all the using declarations, which could result in unexpected behavior. It might be safe to move the using declarations into class ...

Top 50 recent answers are included