'use strict';
var transform = function transform(value, predicate, mutator) {
if (predicate(value)) {
return mutator(value);
}
return value;
};
var height = 69;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Verison 0 | |
'use strict'; | |
var counterFactory = function counterFactory() { | |
return function() {}; | |
}; | |
var firstCounter = counterFactory(); | |
// firstCounter contains a reference to | |
// a new instance of the minimal function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var age = function age() { | |
var dob = new Date(this.dob); | |
var today = new Date(); | |
var thisYear = today.getFullYear(); | |
if (dob.getMonth() > today.getMonth() || | |
dob.getMonth() === today.getMonth() && | |
dob.getDate() >= today.getDate()) { | |
thisYear -= 1; | |
} |
var arrayTimes2 = function arrayTimes2(array) {
for (var i = 0; i < array.length; i++) {
array[i] *= 2;
}
};
var product2 = function product2(nums) {
var result = 1;
for (var i = 0; i < nums.length; i++) {
result *= nums[i];
}
return result;
var max = function max() {
// grab the first number to compare against
// this will be undefined if arguments is empty
var maxValue = arguments[0];
// loop through the remaining numbers
for (var i = 1; i < arguments.length; i++) {
// if the current element is greater
// than the maxValue
if (arguments[i] > maxValue) {