From 3eb5d4e3ee526c0e8f4387f81d1fd3edc0e84d4a Mon Sep 17 00:00:00 2001
From: Roberra0 <roberra.aklilu@gmail.com>
Date: Sun, 18 Jun 2023 11:57:02 -0700
Subject: [PATCH] completed assignments

---
 04_removeFromArray/removeFromArray.js      | 11 +++++++++--
 04_removeFromArray/removeFromArray.spec.js | 12 ++++++------
 05_sumAll/sumAll.js                        | 19 ++++++++++++++++++-
 05_sumAll/sumAll.spec.js                   | 10 +++++-----
 4 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/04_removeFromArray/removeFromArray.js b/04_removeFromArray/removeFromArray.js
index 1bedeb0..708e42b 100644
--- a/04_removeFromArray/removeFromArray.js
+++ b/04_removeFromArray/removeFromArray.js
@@ -1,6 +1,13 @@
-const removeFromArray = function() {
-
+const removeFromArray = function(localArray, ...args) {
+    for (let i of args){
+        indexRemove = localArray.indexOf(i);
+        if(indexRemove != -1){
+            localArray.splice(indexRemove,1);
+        }
+    }
+    return localArray;
 };
 
+removeFromArray([1, 2, 3, 4], 3);
 // Do not edit below this line
 module.exports = removeFromArray;
diff --git a/04_removeFromArray/removeFromArray.spec.js b/04_removeFromArray/removeFromArray.spec.js
index 21f34cf..c17239a 100644
--- a/04_removeFromArray/removeFromArray.spec.js
+++ b/04_removeFromArray/removeFromArray.spec.js
@@ -4,22 +4,22 @@ describe('removeFromArray', () => {
   test('removes a single value', () => {
     expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
   });
-  test.skip('removes multiple values', () => {
+  test('removes multiple values', () => {
     expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
   });
-  test.skip('ignores non present values', () => {
+  test('ignores non present values', () => {
     expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
   });
-  test.skip('ignores non present values, but still works', () => {
+  test('ignores non present values, but still works', () => {
     expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
   });
-  test.skip('can remove all values', () => {
+  test('can remove all values', () => {
     expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
   });
-  test.skip('works with strings', () => {
+  test('works with strings', () => {
     expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
   });
-  test.skip('only removes same type', () => {
+  test('only removes same type', () => {
     expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
   });
 });
diff --git a/05_sumAll/sumAll.js b/05_sumAll/sumAll.js
index 00880c7..7673368 100644
--- a/05_sumAll/sumAll.js
+++ b/05_sumAll/sumAll.js
@@ -1,6 +1,23 @@
-const sumAll = function() {
+// Dont use summation formula
 
+const sumAll = function(start, end) {
+    let total = 0;
+    const min = Math.min(start, end);
+    const max = Math.max(start, end);
+
+    if (start < 0 || typeof start !== "number"){
+        return "ERROR";
+    }
+    if (end < 0 ||  typeof end !== "number"){
+        return "ERROR";
+    }
+
+    for(let i=0; i < max-min+1; i++){
+        total += min+i;
+    }
+    return total;
 };
 
+console.log(sumAll(10,"90"));
 // Do not edit below this line
 module.exports = sumAll;
diff --git a/05_sumAll/sumAll.spec.js b/05_sumAll/sumAll.spec.js
index 1a9fb7c..a171e5f 100644
--- a/05_sumAll/sumAll.spec.js
+++ b/05_sumAll/sumAll.spec.js
@@ -4,19 +4,19 @@ describe('sumAll', () => {
   test('sums numbers within the range', () => {
     expect(sumAll(1, 4)).toEqual(10);
   });
-  test.skip('works with large numbers', () => {
+  test('works with large numbers', () => {
     expect(sumAll(1, 4000)).toEqual(8002000);
   });
-  test.skip('works with larger number first', () => {
+  test('works with larger number first', () => {
     expect(sumAll(123, 1)).toEqual(7626);
   });
-  test.skip('returns ERROR with negative numbers', () => {
+  test('returns ERROR with negative numbers', () => {
     expect(sumAll(-10, 4)).toEqual('ERROR');
   });
-  test.skip('returns ERROR with non-number parameters', () => {
+  test('returns ERROR with non-number parameters', () => {
     expect(sumAll(10, "90")).toEqual('ERROR');
   });
-  test.skip('returns ERROR with non-number parameters', () => {
+  test('returns ERROR with non-number parameters', () => {
     expect(sumAll(10, [90, 1])).toEqual('ERROR');
   });
 });