I’m following this lesson: http://nathansjslessons.appspot.com/lesson?id=1040
These are the instructions:
Define a function named applyTest that takes two arguments, a function
f and an input x. Your function should return a list that contains x,
the function f on the input x, and the function f on the input 0.
This is what I’ve done so far:
var f = function (x) {
return x + 2;
};
var g = function (x) {
return x * 3;
};
var applyTest = function (f, x) {
return [x, f(2), f(0)];
};
and this is what JSLint is saying:
PASSED No JSLint errors
PASSED applyTest is a function
PASSED applyTest(f, 1)[0] === 1
FAILED applyTest(f, 1)[1] === 3 (4 !== 3)
PASSED applyTest(f, 1)[2] === 2
PASSED applyTest(f, 2).compareArrays([2, 4, 2])
FAILED applyTest(g, 3).compareArrays([3, 9, 0])
How do I correct that code in order to pass the lesson?
bad
good