From e23d1ffeec978dcf5ea28794dc06ef21e1405654 Mon Sep 17 00:00:00 2001 From: MohJamal Date: Thu, 4 Feb 2021 02:21:59 -0800 Subject: [PATCH 1/2] first commit --- firstToyProblem.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firstToyProblem.js b/firstToyProblem.js index b0873e7..0b3223d 100644 --- a/firstToyProblem.js +++ b/firstToyProblem.js @@ -5,5 +5,6 @@ */ function minimum(array) { - return; + let arr = array.sort((a,b)=> a-b ); + return arr[0]; } From f0c29043d83a7b69f149e1e65920b431eaec9259 Mon Sep 17 00:00:00 2001 From: MohJamal Date: Fri, 5 Feb 2021 19:08:42 -0800 Subject: [PATCH 2/2] ToyProblem - 2 - solved --- sumOfPairNumber.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sumOfPairNumber.js b/sumOfPairNumber.js index 82412dc..6043489 100644 --- a/sumOfPairNumber.js +++ b/sumOfPairNumber.js @@ -7,6 +7,42 @@ */ function sumPair(array) { //your code goes here + if(Array.isArray(array)){ + let sum=0; + array.map( e => { + if(e %2 ==0){ + sum+= e; + } + + }) + console.log(sum); + }else{ + let pairArr=[]; + let res=""; + for(const prop in array){ + if(array[prop] %2 ==0){ + pairArr.push(prop); + } + } + + if(pairArr.length === 1){ + res=`${pairArr[0]} has pair values` + }else{ + pairArr.map( (e,i) =>{ + if(i != pairArr.length-1){ + res += `${e} & `; + }else{ + res+=`${e} have pair values`; + } + }) + } + console.log(res); + + } + + + + } /**