From 246e2b4493a60adbe9961571304e4b04ab6a3474 Mon Sep 17 00:00:00 2001 From: HassanGhazy Date: Thu, 4 Feb 2021 16:14:49 +0200 Subject: [PATCH 1/3] solve firstToyProblem --- firstToyProblem.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; } From a0a640c3e01f37d82dae6f5c38343581a85765f8 Mon Sep 17 00:00:00 2001 From: Hassan Ghazy Sammour <46076264+HassanGhazy@users.noreply.github.com> Date: Sun, 7 Feb 2021 00:13:55 +0200 Subject: [PATCH 2/3] solve toyProblem2 --- sumOfPairNumber.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sumOfPairNumber.js 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 From ee5a5553464c2a83434fbcbc7b092a64dcfcbbd6 Mon Sep 17 00:00:00 2001 From: Hassan Ghazy Sammour <46076264+HassanGhazy@users.noreply.github.com> Date: Sun, 7 Feb 2021 00:14:16 +0200 Subject: [PATCH 3/3] Delete hey.txt --- hey.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 hey.txt diff --git a/hey.txt b/hey.txt deleted file mode 100644 index e69de29..0000000