JS: basic closure, reverse parameters, etc.

by lasha

JavaScript

var divide2 = function(x, y) {
    return x / y;
};
var reverseArguments2 = function(func) {
    return function(a, b) {
        return divide2(b, a);
    };
};
var notDivide2 = reverseArguments2(notDivide2);

console.log(notDivide2);
console.log("10 / 2 is: " + divide2(10, 2));
console.log("10 / 2 is not: " + notDivide2(10, 2));