From 2f1d9d1bd19689f0437d56af3dd54b1e9886c6ec Mon Sep 17 00:00:00 2001 From: Andrew Eskenazi Date: Wed, 7 Jun 2017 19:28:23 -0600 Subject: [PATCH] first commit, 3 passing tests. --- every/core.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/every/core.js b/every/core.js index 0ceec9a..251c870 100644 --- a/every/core.js +++ b/every/core.js @@ -1,23 +1,41 @@ // Check to see if all elements in an array // are even numbers. -function allEven (input) { - return input; -}; +function allEven(input){ + for(let i = 0; i < input.length; i++) { + if(input[i] % 2 !== 0){ + return false; + } + } + return true; +} + // Check to see if all elements in an array // are of the same type. function allSameType (input) { - return input; + for(let i = 1; i < input.length; i++) { + if(typeof input[i] !== typeof input[i-1]){ + return false; + } + } + return true; }; // Check to see if every element in the matrix is // an array and that every element in the array is // greater than 0. -function positiveMatrix (input) { - return input; +function positiveMatrix(input) { + for (let i = 0; i < input.length; i++) { + for (var j = 0; j < 3; j++) { + if (input[i][j] <= 0) { + return false; + } + } + } + return true; }; // Check that all items in an array are strings