This forum is now read-only. Please use our new forums at

Big O Forum

View Course » View Exercise

596 points
Submitted by
almost 6 years ago

Are there errors in the code?

Hi, I found the correct answer: O(2^n).
However, I think there are problems in the code:

  • console.log(binary(3)); gives me TypeError:&nbspObject.keys&nbspis&nbspnot&nbspa&nbspfunction
  • isn't it better to insert ; after } in lines 8 and 11?
  • I'm not so sure the given code really calculates an array of all binary strings of length n; if it does, I don't understand why. I can't try it and figure it out because of the error I get. Thank you for your attention, bye! M.

0 votes


I couldn't say why you might be getting that error... Try using the reset button and see if the error persists. If that doesn't work then try switching browsers.

389 points
Submitted by
Eric Summers
almost 6 years ago

1 Comment

4f8f6ea95a87fe00030031ad_732049700 Eric Summers almost 6 years ago

Also, the semicolons on 8 and 11 are optional. Feel free to include them if you like, but the code works without them.