From dc3149b918ae221bfb1b2693f97798ad2c0107bf Mon Sep 17 00:00:00 2001 From: ashjanraja Date: Wed, 3 Feb 2021 22:02:43 +0200 Subject: [PATCH 1/3] add solve the ToyProblem --- firstToyProblem.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/firstToyProblem.js b/firstToyProblem.js index b0873e7..a71631a 100644 --- a/firstToyProblem.js +++ b/firstToyProblem.js @@ -4,6 +4,5 @@ * without using any pre build in function */ -function minimum(array) { - return; -} + +Math.min(1,10,5,-3,100) \ No newline at end of file From 8face7e0216a753444c40b8286cbab4d49cabfa1 Mon Sep 17 00:00:00 2001 From: Ashjan Raja <71934289+ashjanraja@users.noreply.github.com> Date: Wed, 3 Feb 2021 22:34:29 +0200 Subject: [PATCH 2/3] Update firstToyProblem.js --- firstToyProblem.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firstToyProblem.js b/firstToyProblem.js index a71631a..00dc124 100644 --- a/firstToyProblem.js +++ b/firstToyProblem.js @@ -5,4 +5,7 @@ */ -Math.min(1,10,5,-3,100) \ No newline at end of file +function minimum(array) { + return Math.min(...array); +} +console.log(minimum([1,10,5,-3,100])); From c266d7a3bf2f6c40102fcb8a39e64e6a0d263704 Mon Sep 17 00:00:00 2001 From: ashjanraja Date: Fri, 5 Feb 2021 17:47:00 +0200 Subject: [PATCH 3/3] I wrote a function that returns the sum of the pair numbers within the array --- sumOfPairNumber.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sumOfPairNumber.js b/sumOfPairNumber.js index 82412dc..f9a39e7 100644 --- a/sumOfPairNumber.js +++ b/sumOfPairNumber.js @@ -5,10 +5,23 @@ * * sumPair([2,4,9,73])=>6 */ + function sumPair(array) { - //your code goes here + var sum = 0; + for (var j = 0; j < array.length; j++){ + if (array[j] % 2 == 0) { + sum += array[j]; + } + + } + return sum; + } +console.log(sumPair([1,6,100,346,761,249])); +console.log(sumPair([2,4,9,73])); + + /** * bonus points *