Skip to content
Advertisement

Tag: recursion

Javascript – deepEqual Comparison

Question (From Eloquent Javascript 2nd Edition, Chapter 4, Exercise 4): Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with the same properties whose values are also equal when compared with a recursive call to deepEqual. Test Cases: My code: I think I have the general idea down;

Recursive function returns undefined

I have a function which calculates taxes. I can’t see why it doesn’t stop the recursion. Answer In this arm of your function: you are not returning a value from the function or setting returnTax. When you don’t return anything, the return value is undefined. Perhaps, you want this:

trouble with recursion; parsing JSON

I have a json object like this: …and I’m trying to iterate through it and get a total count on the “text” objects. I can’t seem to be able to get something recursive working.. I think I’m missing a base-level understanding of both json and recursion.. After a couple of days of variations on this: I’ve come to the conclusion

Advertisement