Ad
  • Custom User Avatar

    It breaks when end can legally be 0 though.

    Better ( now; it hasn't always been available ) is function friday13(start,end=start). See MDN.

  • Custom User Avatar

    Nice one: "end = end || start" I always use conditional statement instead...

  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I did something like this and it kept giving me errors... happy to know i was on the right track...

  • Custom User Avatar

    hi,

    i don't think it is the safest think to do. actually this method (evilTwin) is returning the global object (window) to be the evil twin of "obj" object.

    i see some problems in doing that:

    1. first of all it is changing the global object (is changing its prototype);

    2. second, if this method is called twice for two different "obj" objects, the global object will be realocated to be the evil twin of the second object and the first object will remain without its evil twin;

    3. if this function is executed in a strict mode "use strict", the "this" value will no longer be the global object, but it will be undefined, resulting in an error beeing thrown (TypeError).

    so, this solution was good here, but don't do this in a real application. it is not safe. ;)