diff --git a/docs/pull_request_template.md b/docs/pull_request_template.md new file mode 100644 index 0000000..821abe5 --- /dev/null +++ b/docs/pull_request_template.md @@ -0,0 +1,27 @@ +### Description + + + +**Monday task:** MONDAY- + + + + + + + +### Screenshot(s): + + diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..b5ebc36 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,27 @@ +### Description + + + +**Monday task:** MONDAY- + + + + + + + +### Screenshot(s): + + diff --git a/shapes.js b/shapes.js index 20df403..9288fc4 100644 --- a/shapes.js +++ b/shapes.js @@ -9,6 +9,12 @@ class Rectangle { } } +class CircleGetsTheSquare { + constructor(circumference, radius) { + this.circumference = circumference + this.radius = radius + } + class Square extends Rectangle { constructor(x) { super(x, x) diff --git a/underscore.js b/underscore.js index 783900f..b69ebd7 100644 --- a/underscore.js +++ b/underscore.js @@ -27,6 +27,47 @@ _.min = function(obj, iteratee, context) { return result; }; +_.sampleThis = function(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = _.values(obj); + return obj[_.random(obj.length - 1)]; + } + var sample = isArrayLike(obj) ? _.clone(obj) : _.values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = _.random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); +}; + +_.sortBy = function(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return _.pluck( + _.map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), + "value" + ); +}; + _.shuffle = function(obj) { return _.sample(obj, Infinity); };