Ad
  • Custom User Avatar

    I removed all tests where expected and actual values were switched. But there are still tests in the form

    let k = global.expected;
    assert.strictEqual(next(), k, "Modify expected variable");
    
  • Custom User Avatar

    Yes, there are also test cases in the form strictEqual(expected, next()).

  • Custom User Avatar

    The No modify expected variable test looks like this:

    let k = global.expected;
    assert.strictEqual(next(), k, "Modify expected variable");
    

    Hint: you need to do something outside of the function next in order to pass this test. (The initial solution has this line: // Hint: Initial code.)

  • Custom User Avatar

    Please post your current solution in a comment with the spoiler flag.

  • Default User Avatar
  • Default User Avatar

    I've been trying to solve it for one hour and still can't find the solution...

  • Default User Avatar

    Do you have enough thumb down?

  • Custom User Avatar

    Yep, sorry for any lack of clarity. JS cannot replace an arbitrary function reference (e.g. function (someFunc) { ... } cannot "swap out" someFunc, except as a locally-scoped binding). It can replace a variable or property name referring to a function (e.g. function(obj, methodName) { ... } CAN substitute a new value into object[methodName]). That latter can be used in a hacky way to replace top-level variables: replaceMethod(global, 'funcName') could reassign global[funcName].