2 ms·
I wonder how I would have done in that interview given that I don't know JS. My overall answers would have been: - Well, I dont know JS, but in order to proces
by tetha 16y ago
I wonder how I would have done in that interview given that I don't know JS. My overall answers would have been:
- Well, I dont know JS, but in order to process a node, I have to apply the function to the value and recurse for each value in the array. This also handles leafes properly, because they have no children and thus no recursion occurs. Thus, I'd have to grab some web browser now and find some forach-loop and some functio-definition-syntax in JS now.
- In order to sum values up, I'd need some function which adds the value to an accumulator in place and destructively (such that the new value replaces the old value). Should be easy using closures or, in the worst case, a simple small object.
Overall, this took about 3 minutes. If I would search for javascript syntax now, I'd probably need around 10 - 20 additional minutes to get everything working.