diff --git a/firstToyProblem.js b/firstToyProblem.js index b0873e7..91acc2c 100644 --- a/firstToyProblem.js +++ b/firstToyProblem.js @@ -1,9 +1,10 @@ -/** - * [1,10,5,-3,100] - * create a function that finds the minimum - * without using any pre build in function - */ function minimum(array) { - return; + let min = array[0]; + for (let i = 0; i < array.length; i++) { + if (array[i] < min) { + min = array[i]; + } + } + return min; } diff --git a/hey.txt b/hey.txt deleted file mode 100644 index e69de29..0000000 diff --git a/sumOfPairNumber.js b/sumOfPairNumber.js new file mode 100644 index 0000000..4818c7f --- /dev/null +++ b/sumOfPairNumber.js @@ -0,0 +1,16 @@ +/** + * write a function that returns the sum of the pair numbers inside an array + * + * exple sumPair([1,6,100,346,761,249])=>452 + * + * sumPair([2,4,9,73])=>6 + */ +function sumPair(array) { + let sum = 0; + for (let i = 0; i < array.length; i++) { + if (array[i] % 2 === 0) { + sum += array[i]; + } + } + return sum; +} \ No newline at end of file