diff --git a/leapYears/leapYears.js b/leapYears/leapYears.js index bb2f54d..48a9a03 100644 --- a/leapYears/leapYears.js +++ b/leapYears/leapYears.js @@ -1,5 +1,6 @@ const leapYears = function(year) { - return year % 4 === 0 && (year % 100 !==0 || year % 400 ===0) -} + + return year % 4 === 0 && (year % 100 !== 0 || year % 400 == 0) +}; module.exports = leapYears diff --git a/leapYears/leapYears.spec.js b/leapYears/leapYears.spec.js index 0d4d7d4..f4cdea8 100644 --- a/leapYears/leapYears.spec.js +++ b/leapYears/leapYears.spec.js @@ -4,19 +4,19 @@ describe('leapYears', function() { it('works with non century years', function() { expect(leapYears(1996)).toEqual(true); }); - xit('works with non century years', function() { + it('works with non century years', function() { expect(leapYears(1997)).toEqual(false); }); - xit('works with ridiculously futuristic non century years', function() { + it('works with ridiculously futuristic non century years', function() { expect(leapYears(34992)).toEqual(true); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(1900)).toEqual(false); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(1600)).toEqual(true); }); - xit('works with century years', function() { + it('works with century years', function() { expect(leapYears(700)).toEqual(false); }); }); diff --git a/removeFromArray/removeFromArray.js b/removeFromArray/removeFromArray.js index 11efd5c..9655f27 100644 --- a/removeFromArray/removeFromArray.js +++ b/removeFromArray/removeFromArray.js @@ -1,5 +1,15 @@ -const removeFromArray = function() { +const removeFromArray = function(...arg) { + const thisArray = arg[0]; + let newArray = [] -} + thisArray.forEach((e)=> { + if(!arg.includes(e)){ + newArray.push(e); + } + }); + + return newArray; + +}; module.exports = removeFromArray diff --git a/removeFromArray/removeFromArray.spec.js b/removeFromArray/removeFromArray.spec.js index f60239a..0fc7b78 100644 --- a/removeFromArray/removeFromArray.spec.js +++ b/removeFromArray/removeFromArray.spec.js @@ -4,22 +4,22 @@ describe('removeFromArray', function() { it('removes a single value', function() { expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]); }); - xit('removes multiple values', function() { + it('removes multiple values', function() { expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]); }); - xit('ignores non present values', function() { + it('ignores non present values', function() { expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]); }); - xit('ignores non present values, but still works', function() { + it('ignores non present values, but still works', function() { expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]); }); - xit('can remove all values', function() { + it('can remove all values', function() { expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]); }); - xit('works with strings', function() { + it('works with strings', function() { expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]); }); - xit('only removes same type', function() { + it('only removes same type', function() { expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]); }); }); diff --git a/repeatString/repeatString.js b/repeatString/repeatString.js index 770119a..c682477 100644 --- a/repeatString/repeatString.js +++ b/repeatString/repeatString.js @@ -1,4 +1,11 @@ -const repeatString = function() { +const repeatString = function(word , times) { + let str = ''; + if ( times < 0) return 'ERROR'; + + for( let i = 0 ; i < times ; i++){ + str += word; + } + return str; } diff --git a/repeatString/repeatString.spec.js b/repeatString/repeatString.spec.js index 7124484..20ec844 100644 --- a/repeatString/repeatString.spec.js +++ b/repeatString/repeatString.spec.js @@ -4,19 +4,19 @@ describe('repeatString', function() { it('repeats the string', function() { expect(repeatString('hey', 3)).toEqual('heyheyhey'); }); - xit('repeats the string many times', function() { + it('repeats the string many times', function() { expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey'); }); - xit('repeats the string 1 times', function() { + it('repeats the string 1 times', function() { expect(repeatString('hey', 1)).toEqual('hey'); }); - xit('repeats the string 0 times', function() { + it('repeats the string 0 times', function() { expect(repeatString('hey', 0)).toEqual(''); }); - xit('returns ERROR with negative numbers', function() { + it('returns ERROR with negative numbers', function() { expect(repeatString('hey', -1)).toEqual('ERROR'); }); - xit('repeats the string a random amount of times', function () { + it('repeats the string a random amount of times', function () { /*The number is generated by using Math.random to get a value from between 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it equals a number between 0 to 999 (this number will change everytime you run @@ -27,7 +27,7 @@ describe('repeatString', function() { was randomaly generated. */ expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number); }); - xit('works with blank strings', function() { + it('works with blank strings', function() { expect(repeatString('', 10)).toEqual(''); }); }); diff --git a/reverseString/reverseString.js b/reverseString/reverseString.js index febb577..e9da1ea 100644 --- a/reverseString/reverseString.js +++ b/reverseString/reverseString.js @@ -1,5 +1,5 @@ -const reverseString = function() { - +const reverseString = function(str) { + return str.split('').reverse().join(''); } module.exports = reverseString diff --git a/reverseString/reverseString.spec.js b/reverseString/reverseString.spec.js index fe135e9..86ab904 100644 --- a/reverseString/reverseString.spec.js +++ b/reverseString/reverseString.spec.js @@ -5,14 +5,14 @@ describe('reverseString', function() { expect(reverseString('hello')).toEqual('olleh'); }); - xit('reverses multiple words', function() { + it('reverses multiple words', function() { expect(reverseString('hello there')).toEqual('ereht olleh') }) - xit('works with numbers and punctuation', function() { + it('works with numbers and punctuation', function() { expect(reverseString('123! abc!')).toEqual('!cba !321') }) - xit('works with blank strings', function() { + it('works with blank strings', function() { expect(reverseString('')).toEqual('') }) }); diff --git a/sumAll/sumAll.spec.js b/sumAll/sumAll.spec.js index 520adc1..2a584a6 100644 --- a/sumAll/sumAll.spec.js +++ b/sumAll/sumAll.spec.js @@ -4,19 +4,19 @@ describe('sumAll', function() { it('sums numbers within the range', function() { expect(sumAll(1, 4)).toEqual(10); }); - xit('works with large numbers', function() { + it('works with large numbers', function() { expect(sumAll(1, 4000)).toEqual(8002000); }); - xit('works with larger number first', function() { + it('works with larger number first', function() { expect(sumAll(123, 1)).toEqual(7626); }); - xit('returns ERROR with negative numbers', function() { + it('returns ERROR with negative numbers', function() { expect(sumAll(-10, 4)).toEqual('ERROR'); }); - xit('returns ERROR with non-number parameters', function() { + it('returns ERROR with non-number parameters', function() { expect(sumAll(10, "90")).toEqual('ERROR'); }); - xit('returns ERROR with non-number parameters', function() { + it('returns ERROR with non-number parameters', function() { expect(sumAll(10, [90, 1])).toEqual('ERROR'); }); });