2012-04-14 12:57:10Morris
[JavaScript] Function calls as values
// Define quarter here.
var quarter = function(n) {
return n/4;
};
if (quarter(4) === 1) {
console.log("The statement is true.");
} else {
console.log("The statement is false.");
}
var cube = function(n) {
return n*n*n;
}
var square = function (x) {
return x * x;
};
var cube = function (x) {
return square(x)*x;
};
var isMultipleOfThree = function (x) {
return x % 3 === 0;
};
var isNotMultipleOfThree = function (x) {
return !isMultipleOfThree(x);
};
var isOdd = function(n) {
return n%2 === 1;
};
var isEven = function(n) {
return !isOdd(n);
};
var quarter = function(n) {
return n/4;
};
if (quarter(4) === 1) {
console.log("The statement is true.");
} else {
console.log("The statement is false.");
}
var cube = function(n) {
return n*n*n;
}
var square = function (x) {
return x * x;
};
var cube = function (x) {
return square(x)*x;
};
var isMultipleOfThree = function (x) {
return x % 3 === 0;
};
var isNotMultipleOfThree = function (x) {
return !isMultipleOfThree(x);
};
var isOdd = function(n) {
return n%2 === 1;
};
var isEven = function(n) {
return !isOdd(n);
};