From 68aa9d2ed9ec72b76388f81d241fb55dc0b94fc6 Mon Sep 17 00:00:00 2001 From: sashajustice Date: Fri, 5 May 2017 15:02:41 -0700 Subject: [PATCH 1/3] set of all algorithms --- src/FizzBuzz.js | 24 ++++++++++++++++++++ src/collatzconjecture.js | 27 +++++++++++++++++++++++ src/factorial.js | 26 ++++++++++++++++++++++ src/fibonacci.js | 27 +++++++++++++++++++++++ src/isPalindrome.js | 35 +++++++++++++++++++++++++++++ src/setIntersection.js | 28 ++++++++++++++++++++++++ src/setSymmetricDifference.js | 10 +++++++++ src/setUnion.js | 40 ++++++++++++++++++++++++++++++++++ src/setcomplement.js | 21 ++++++++++++++++++ test/collatzconjecture_test.js | 25 +++++++++++++++++++++ test/factorial_test.js | 24 ++++++++++++++++++++ test/fibonacci_test.js | 22 +++++++++++++++++++ test/fizzBuzz_test.js | 19 ++++++++++++++++ test/isPalindrome.js | 21 ++++++++++++++++++ test/makeChange_test.js | 2 ++ test/setComplement_test.js | 10 +++++++++ test/setIntersection_test.js | 10 +++++++++ test/setUnion_test.js | 11 ++++++++++ 18 files changed, 382 insertions(+) create mode 100644 src/FizzBuzz.js create mode 100644 src/collatzconjecture.js create mode 100644 src/factorial.js create mode 100644 src/fibonacci.js create mode 100644 src/isPalindrome.js create mode 100644 src/setIntersection.js create mode 100644 src/setSymmetricDifference.js create mode 100644 src/setUnion.js create mode 100644 src/setcomplement.js create mode 100644 test/collatzconjecture_test.js create mode 100644 test/factorial_test.js create mode 100644 test/fibonacci_test.js create mode 100644 test/fizzBuzz_test.js create mode 100644 test/isPalindrome.js create mode 100644 test/setComplement_test.js create mode 100644 test/setIntersection_test.js create mode 100644 test/setUnion_test.js diff --git a/src/FizzBuzz.js b/src/FizzBuzz.js new file mode 100644 index 0000000..61292be --- /dev/null +++ b/src/FizzBuzz.js @@ -0,0 +1,24 @@ +export default function FizzBuzz({arr}) { + +fizzBuzz + +Return an array of numbers from 1 to 100. + +For multiples of three, use the string Fizz instead of the number and for multiples of five replace with Buzz. + +For numbers which are multiples of both three and five replace with FizzBuzz. + +fizzBuzz() +// => [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz', ...] + + +fizzBuzz (arr) => +for(const i = 0; i < arr.length; i ++) { + if(n % 3 === 0) { + console.log ("Fizz") + } + else if (n % 5 === 0) { + console.log ("Buzz") + else { + console.log ("FizzBuzz") + } diff --git a/src/collatzconjecture.js b/src/collatzconjecture.js new file mode 100644 index 0000000..8be627b --- /dev/null +++ b/src/collatzconjecture.js @@ -0,0 +1,27 @@ +export default function collatzConjecture({}) { + + +collatzConjecture + +Return the Collatz sequence for a given number. + +The Collatz sequence for any positive integer n is defined as follows: + +If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to obtain 3n + 1. Repeat the process until you reach 1. +collatzConjecture(1) +// => [1] + +collatzConjecture(7) +// => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1] + +collatzConjecture (n) => + + const seq = 0 + while ( i > 1){ + if(n % 2 ) { + n/2; + } else if (n % 3) { + (3 * n) + 1; + } + return seq + } diff --git a/src/factorial.js b/src/factorial.js new file mode 100644 index 0000000..84cf527 --- /dev/null +++ b/src/factorial.js @@ -0,0 +1,26 @@ +export default function factorial {()} { + + +Factorial = the product of an integer and all the integers below it; e.g., factorial four ( 4! ) is equal to 24. + + + +Return the factorial of a number. + +factorial(5) +// => 120 + + + +factorial (x) => + if(x === 0) { + return 1; + } + if(x < 0 ) { + return undefined; + } + for(var i = x; --i; ) { + x *= i; + } + return x; +} diff --git a/src/fibonacci.js b/src/fibonacci.js new file mode 100644 index 0000000..8f22844 --- /dev/null +++ b/src/fibonacci.js @@ -0,0 +1,27 @@ +export default function fibonnaci({}){ + +//npm test + + + + +Fibonacci + +Return an array of Fibonacci numbers to the nth position. + +fibonacci(10) +// => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] + + +function fibonacci(num){ + var x = 1, y = 0, temp; + + while (num >= 0){ + temp = x; + x = x + y; + y = temp; + num--; + } + + return y; +} diff --git a/src/isPalindrome.js b/src/isPalindrome.js new file mode 100644 index 0000000..bb6a958 --- /dev/null +++ b/src/isPalindrome.js @@ -0,0 +1,35 @@ +export default function isPalindrome({string}) { + + + +Palindrome = a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. + +isPalindrome + +Determine if a string is a palindrome. Return true or false. + +Ignore punctuation, spacing, and case sensitivity. + +isPalindrome('radar') +// => true + +isPalindrome('bananas') +// => false + +isPalindrome('A man, a plan, a canal: Panama') +// => true + + + +Palindrome(string) => { + const reverseString = ''; + for(const k in string){ + reverseString += string[(string.length - k) - 1]; + } + if(string === reverseString){ + console.log('true'); + } else { + console.log("false"); + } + } +} diff --git a/src/setIntersection.js b/src/setIntersection.js new file mode 100644 index 0000000..0c2cf08 --- /dev/null +++ b/src/setIntersection.js @@ -0,0 +1,28 @@ +export default function setIntersection {()} { + + + + + +Return the intersection of two sets. + +const a = [1, 2, 3, 4] +const b = [2, 4, 6, 8] +setIntersection(a, b) +// => [2, 4] + + + +setIntersection () => +let arr = [1, 2, 3, 4] +let b = [2, 4, 6, 8] +setIntersection(a, b) +let sorted_arr = arr.slice().sort(); +let results = []; +for (var i = 0; i < arr.length - 1; i++) { + if (sorted_arr[i + 1] == sorted_arr[i]) { + results.push(sorted_arr[i]); + } +} + +console.log(results); diff --git a/src/setSymmetricDifference.js b/src/setSymmetricDifference.js new file mode 100644 index 0000000..a7f04de --- /dev/null +++ b/src/setSymmetricDifference.js @@ -0,0 +1,10 @@ +export default function setSymmetricDifference({}) { + +setSymmetricDifference + +Return the symmetric difference of two sets. + +const a = [1, 2, 3, 4] +const b = [2, 4, 6, 8] +setSymmetricDifference(a, b) +// => [1, 3, 6, 8] diff --git a/src/setUnion.js b/src/setUnion.js new file mode 100644 index 0000000..99dd42a --- /dev/null +++ b/src/setUnion.js @@ -0,0 +1,40 @@ +export default function setUnion {()} { + + + + + Return the union of two sets. + + const a = [1, 2, 3, 4] + const b = [2, 4, 6, 8] + setUnion(a, b) + // => [1, 2, 3, 4, 6, 8] + +setUnion (arr) => //could be a quicksort algorithm + +const union = []; + for (const i = 0; i < arr.length; i++) { + for (const j = 0; i < arr.length; j++){ + const repeat = array[i]; + if (union.indexOf(repeat) !== -1 ) { + return true; + } + union.push(repeat); + } + return false; + } + } +} + +/*function hasDuplicates(array) { + var valuesSoFar = []; + for (var i = 0; i < array.length; ++i) { + var value = array[i]; + if (valuesSoFar.indexOf(value) !== -1) { + return true; + } + valuesSoFar.push(value); + } + return false; +} +*/ diff --git a/src/setcomplement.js b/src/setcomplement.js new file mode 100644 index 0000000..991b0a3 --- /dev/null +++ b/src/setcomplement.js @@ -0,0 +1,21 @@ +export defautl function setComplement ({}) { + +} + + + +setComplement + +Return the complement of two sets. + +const a = [1, 2, 3, 4] +const b = [2, 4, 6, 8] +setComplement(a, b) +// => [6, 8] + + + set.complement = function(a, b) { + return process(a, b, function(freq) { + return freq === 1; + }); + }; diff --git a/test/collatzconjecture_test.js b/test/collatzconjecture_test.js new file mode 100644 index 0000000..64a3c8c --- /dev/null +++ b/test/collatzconjecture_test.js @@ -0,0 +1,25 @@ +import { expect } from 'chai' +import collatzConjecture from '../src/collatzConjecture_test' + +describe + + +expect ('collatzConjecture_test()', function () { + + describe('factorial_test()', function(){ + + it('should be a function', function(){ + expect.factorial_test.to.be.a('function') + }) + + +describe('factorial_test()'{ + expect.factorial_test.to.be.a('function') +}) + + +it('If n is even, divide it by 2 ', function(){ + const Pali = isPalindrome({price: 100, amountGiven: 100}) + expect(change).to.be.an('object') + }) +}) diff --git a/test/factorial_test.js b/test/factorial_test.js new file mode 100644 index 0000000..169d040 --- /dev/null +++ b/test/factorial_test.js @@ -0,0 +1,24 @@ +import { expect } from 'chai' +import fizzBuzz from '../src/factorial_test' + + + + + + +describe('factorial_test()', function(){ + + it('should be a function', function(){ + expect.factorial_test.to.be.a('function') +}) + + +it('returns a factorial )', function(){ + const change = factorial({return 1, if 0}) +}) + + + +it('returns factorial', function(){ + expect(factorial({return undefined if < 0)} +}) diff --git a/test/fibonacci_test.js b/test/fibonacci_test.js new file mode 100644 index 0000000..5830117 --- /dev/null +++ b/test/fibonacci_test.js @@ -0,0 +1,22 @@ +import { expect } from 'chai' +import fibonacci from '../src/fibonacci_test' + +describe('fibonacci()', function(){ + +it('should be a function()', function() { + expect((isPalindrome).to.be.a('function') +}) + +//it('returns true when fibonacci = fibonacci', function(){ + //const Pali = fibonacci({price: 100, amountGiven: 100}) + //expect(change).to.be.an('object') + }) +}) + + +describe.only('fibonacci', () => { + + it( 'Returns sum to 10()' => { + expect( sumEvenFibs(10) ).to.equal( 44 ) + }) +}) diff --git a/test/fizzBuzz_test.js b/test/fizzBuzz_test.js new file mode 100644 index 0000000..cde34da --- /dev/null +++ b/test/fizzBuzz_test.js @@ -0,0 +1,19 @@ +import { expect } from 'chai' +import fizzBuzz from '../src/fizzBuzz' + + +describe('FizzBuzz()', function(){ + + it('should be a function', function(){ + expect.FizzBuzz.to.be.a('function') +}) + + +it('returns Fizz when there are multiples of three', function(){ + expect(fizzBuzz({multiplesOfThree: wordReturned: Fizz})).to.deep.equal({ + multiplesOfThree: amountGiven: Fizz}) + + +it('returns Buzz when there are multiples of five', function(){ + expect(fizzBuzz({multiplesOfFive: wordReturned: Buzz})).to.deep.equal({ + multiplesOfFive: amountGiven: Buzz}) diff --git a/test/isPalindrome.js b/test/isPalindrome.js new file mode 100644 index 0000000..b3f557b --- /dev/null +++ b/test/isPalindrome.js @@ -0,0 +1,21 @@ +import { expect } from 'chai' +import isPalindrome from '../src/isPalindrome' + + +describe('isPalindrome()', function(){ + +it('should be a function()', function() { + expect((isPalindrome).to.be.a('function') +}) + +it('returns true when isPalindrome = palindrome', function(){ + const Pali = isPalindrome({price: 100, amountGiven: 100}) + expect(change).to.be.an('object') + }) +}) + +it('returns false if isPalindrome is not a Palindrome,' function(){ + expect(isPalindrome({})).to.deep.equal({ + + }) +}) diff --git a/test/makeChange_test.js b/test/makeChange_test.js index d17098e..d60329d 100644 --- a/test/makeChange_test.js +++ b/test/makeChange_test.js @@ -1,8 +1,10 @@ import { expect } from 'chai' import makeChange from '../src/makeChange' + describe('makeChange()', function(){ + it('should be a function', function(){ expect(makeChange).to.be.a('function') }) diff --git a/test/setComplement_test.js b/test/setComplement_test.js new file mode 100644 index 0000000..a916b8f --- /dev/null +++ b/test/setComplement_test.js @@ -0,0 +1,10 @@ +import { expect } from 'chai' +import setComplement from '../src/setComplement' + + +describe('setComplement()', function(){ + + + it('should be a function', function(){ + expect(setComplement).to.be.a('function') + }) diff --git a/test/setIntersection_test.js b/test/setIntersection_test.js new file mode 100644 index 0000000..8ac24cf --- /dev/null +++ b/test/setIntersection_test.js @@ -0,0 +1,10 @@ +import { expect } from 'chai' +import setintersection from '../src/setIntersection' + + +describe('setIntersection()', function(){ + + + it('should be a function', function(){ + expect(setIntersection).to.be.a('function') + }) diff --git a/test/setUnion_test.js b/test/setUnion_test.js new file mode 100644 index 0000000..7326516 --- /dev/null +++ b/test/setUnion_test.js @@ -0,0 +1,11 @@ +import { expect } from 'chai' +import setUnion from '../src/setUnion' + +describe('setUnion', function () { + + it('should be a function'() { + expect((setUnion).to.be.a('function'){ + + +it('should return ') + expect(()) From bba9689ab6c266130620525b677441f71f3be443 Mon Sep 17 00:00:00 2001 From: sashajustice Date: Fri, 5 May 2017 15:32:22 -0700 Subject: [PATCH 2/3] 2nd draft --- src/FizzBuzz.js | 2 +- src/collatzconjecture.js | 2 +- src/factorial.js | 2 +- src/fibonacci.js | 2 +- src/setIntersection.js | 2 +- src/setSymmetricDifference.js | 23 +++++++++++++++++++++++ src/setcomplement.js | 2 +- test/collatzconjecture_test.js | 2 +- test/setSymmetricalDifference_test.js | 2 ++ 9 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 test/setSymmetricalDifference_test.js diff --git a/src/FizzBuzz.js b/src/FizzBuzz.js index 61292be..4a99852 100644 --- a/src/FizzBuzz.js +++ b/src/FizzBuzz.js @@ -12,7 +12,7 @@ fizzBuzz() // => [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz', ...] -fizzBuzz (arr) => +fizzBuzz (arr) => { for(const i = 0; i < arr.length; i ++) { if(n % 3 === 0) { console.log ("Fizz") diff --git a/src/collatzconjecture.js b/src/collatzconjecture.js index 8be627b..ddbdf4c 100644 --- a/src/collatzconjecture.js +++ b/src/collatzconjecture.js @@ -14,7 +14,7 @@ collatzConjecture(1) collatzConjecture(7) // => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1] -collatzConjecture (n) => +collatzConjecture (n) => { const seq = 0 while ( i > 1){ diff --git a/src/factorial.js b/src/factorial.js index 84cf527..b5aeaf4 100644 --- a/src/factorial.js +++ b/src/factorial.js @@ -12,7 +12,7 @@ factorial(5) -factorial (x) => +factorial (x) => { if(x === 0) { return 1; } diff --git a/src/fibonacci.js b/src/fibonacci.js index 8f22844..d0f6fef 100644 --- a/src/fibonacci.js +++ b/src/fibonacci.js @@ -13,7 +13,7 @@ fibonacci(10) // => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] -function fibonacci(num){ +fibonacci(num) => { var x = 1, y = 0, temp; while (num >= 0){ diff --git a/src/setIntersection.js b/src/setIntersection.js index 0c2cf08..b18c665 100644 --- a/src/setIntersection.js +++ b/src/setIntersection.js @@ -13,7 +13,7 @@ setIntersection(a, b) -setIntersection () => +setIntersection () => { let arr = [1, 2, 3, 4] let b = [2, 4, 6, 8] setIntersection(a, b) diff --git a/src/setSymmetricDifference.js b/src/setSymmetricDifference.js index a7f04de..9b69fbf 100644 --- a/src/setSymmetricDifference.js +++ b/src/setSymmetricDifference.js @@ -8,3 +8,26 @@ const a = [1, 2, 3, 4] const b = [2, 4, 6, 8] setSymmetricDifference(a, b) // => [1, 3, 6, 8] + + + setSymmetricDifference (a,b) => { + let ans = [], cnts = {}; + for (let i = 0; i < arguments.length; i++){ + arguments[i].forEach(function(item) { + if (cnts.hasOwnProperty(item)) { + // increase cnt + ++cnts[item].cnt; + } else { + // initalize cnt and value + cnts[item] = {cnt: 1, val: item}; + } + }); + } + for (let item in cnts) { + if (cnts.hasOwnProperty(item) && cnts[item].cnt === 1) { + ans.push(cnts[item].val); + } + } + + return ans; +} diff --git a/src/setcomplement.js b/src/setcomplement.js index 991b0a3..5ca0df9 100644 --- a/src/setcomplement.js +++ b/src/setcomplement.js @@ -14,7 +14,7 @@ setComplement(a, b) // => [6, 8] - set.complement = function(a, b) { + set.complement = (a, b) => { return process(a, b, function(freq) { return freq === 1; }); diff --git a/test/collatzconjecture_test.js b/test/collatzconjecture_test.js index 64a3c8c..b5fe25f 100644 --- a/test/collatzconjecture_test.js +++ b/test/collatzconjecture_test.js @@ -1,7 +1,7 @@ import { expect } from 'chai' import collatzConjecture from '../src/collatzConjecture_test' -describe + expect ('collatzConjecture_test()', function () { diff --git a/test/setSymmetricalDifference_test.js b/test/setSymmetricalDifference_test.js new file mode 100644 index 0000000..e0fbbfe --- /dev/null +++ b/test/setSymmetricalDifference_test.js @@ -0,0 +1,2 @@ +import { expect } from 'chai' +import collatzConjecture from '../src/collatzConjecture_test' From eb0272516e9c627cb1e88981ed8b7eda8da1d839 Mon Sep 17 00:00:00 2001 From: sashajustice Date: Fri, 5 May 2017 16:52:47 -0700 Subject: [PATCH 3/3] making corrections --- package.json | 1 + src/FizzBuzz.js | 15 ++++++----- src/collatzconjecture.js | 36 ++++++++++++--------------- src/factorial.js | 6 ++--- src/fibonacci.js | 2 -- src/isPalindrome.js | 8 +++--- src/setIntersection.js | 6 ++--- src/setSymmetricDifference.js | 10 ++++---- src/setUnion.js | 4 +-- src/setcomplement.js | 10 ++++---- test/collatzconjecture_test.js | 20 ++++++--------- test/factorial_test.js | 6 ++--- test/fibonacci_test.js | 4 +-- test/isPalindrome.js | 2 +- test/setSymmetricalDifference_test.js | 9 ++++++- test/setUnion_test.js | 5 +--- 16 files changed, 70 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index 71f93c5..5330355 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "mocha": "2.0.1" }, "scripts": { + "build": "babel src -d lib", "test": "mocha --compilers js:babel-register" } } diff --git a/src/FizzBuzz.js b/src/FizzBuzz.js index 4a99852..634175b 100644 --- a/src/FizzBuzz.js +++ b/src/FizzBuzz.js @@ -1,24 +1,27 @@ -export default function FizzBuzz({arr}) { +export default function fizzbuzz(arr) { +} -fizzBuzz +/*fizzBuzz Return an array of numbers from 1 to 100. For multiples of three, use the string Fizz instead of the number and for multiples of five replace with Buzz. -For numbers which are multiples of both three and five replace with FizzBuzz. +For numbers which are multiples of both three and five replace with FizzBuzz.*/ fizzBuzz() // => [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz', ...] fizzBuzz (arr) => { + let arr = []; for(const i = 0; i < arr.length; i ++) { if(n % 3 === 0) { - console.log ("Fizz") + console.log ("fizz") } else if (n % 5 === 0) { - console.log ("Buzz") + console.log ("buzz") else { - console.log ("FizzBuzz") + console.log ("fizzbuzz") } +} diff --git a/src/collatzconjecture.js b/src/collatzconjecture.js index ddbdf4c..ea40e21 100644 --- a/src/collatzconjecture.js +++ b/src/collatzconjecture.js @@ -1,27 +1,23 @@ -export default function collatzConjecture({}) { +export default function collatzconjecture({}) { -collatzConjecture -Return the Collatz sequence for a given number. - -The Collatz sequence for any positive integer n is defined as follows: - -If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to obtain 3n + 1. Repeat the process until you reach 1. -collatzConjecture(1) +/*collatzConjecture(1) // => [1] collatzConjecture(7) -// => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1] - -collatzConjecture (n) => { - - const seq = 0 - while ( i > 1){ - if(n % 2 ) { - n/2; - } else if (n % 3) { - (3 * n) + 1; +// => [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]*/ + + function collatzconjecture (n) { + + const seq = 0 + while ( i > 1){ + if(n % 2 ) { + n/2; + } else if (n % 3) { + (3 * n) + 1; + } + return seq } - return seq - } + } +} diff --git a/src/factorial.js b/src/factorial.js index b5aeaf4..0a3fb2c 100644 --- a/src/factorial.js +++ b/src/factorial.js @@ -1,13 +1,13 @@ export default function factorial {()} { -Factorial = the product of an integer and all the integers below it; e.g., factorial four ( 4! ) is equal to 24. +/*Factorial = the product of an integer and all the integers below it; e.g., factorial four ( 4! ) is equal to 24. -Return the factorial of a number. +Return the factorial of a number.*/ -factorial(5) +//factorial(5) // => 120 diff --git a/src/fibonacci.js b/src/fibonacci.js index d0f6fef..9ab701d 100644 --- a/src/fibonacci.js +++ b/src/fibonacci.js @@ -5,9 +5,7 @@ export default function fibonnaci({}){ -Fibonacci -Return an array of Fibonacci numbers to the nth position. fibonacci(10) // => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] diff --git a/src/isPalindrome.js b/src/isPalindrome.js index bb6a958..90fc596 100644 --- a/src/isPalindrome.js +++ b/src/isPalindrome.js @@ -2,22 +2,22 @@ export default function isPalindrome({string}) { -Palindrome = a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. +/*Palindrome = a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. isPalindrome Determine if a string is a palindrome. Return true or false. -Ignore punctuation, spacing, and case sensitivity. +Ignore punctuation, spacing, and case sensitivity.*/ -isPalindrome('radar') +/*isPalindrome('radar') // => true isPalindrome('bananas') // => false isPalindrome('A man, a plan, a canal: Panama') -// => true +// => true*/ diff --git a/src/setIntersection.js b/src/setIntersection.js index b18c665..13d6ac2 100644 --- a/src/setIntersection.js +++ b/src/setIntersection.js @@ -4,12 +4,12 @@ export default function setIntersection {()} { -Return the intersection of two sets. +/*Return the intersection of two sets. const a = [1, 2, 3, 4] const b = [2, 4, 6, 8] setIntersection(a, b) -// => [2, 4] +// => [2, 4]*/ @@ -19,7 +19,7 @@ let b = [2, 4, 6, 8] setIntersection(a, b) let sorted_arr = arr.slice().sort(); let results = []; -for (var i = 0; i < arr.length - 1; i++) { +for (let i = 0; i < arr.length - 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { results.push(sorted_arr[i]); } diff --git a/src/setSymmetricDifference.js b/src/setSymmetricDifference.js index 9b69fbf..c805e38 100644 --- a/src/setSymmetricDifference.js +++ b/src/setSymmetricDifference.js @@ -1,12 +1,12 @@ export default function setSymmetricDifference({}) { -setSymmetricDifference +//setSymmetricDifference -Return the symmetric difference of two sets. +//Return the symmetric difference of two sets. -const a = [1, 2, 3, 4] -const b = [2, 4, 6, 8] -setSymmetricDifference(a, b) +//const a = [1, 2, 3, 4] +//const b = [2, 4, 6, 8] +//setSymmetricDifference(a, b) // => [1, 3, 6, 8] diff --git a/src/setUnion.js b/src/setUnion.js index 99dd42a..fcd17fb 100644 --- a/src/setUnion.js +++ b/src/setUnion.js @@ -3,12 +3,12 @@ export default function setUnion {()} { - Return the union of two sets. + /*Return the union of two sets. const a = [1, 2, 3, 4] const b = [2, 4, 6, 8] setUnion(a, b) - // => [1, 2, 3, 4, 6, 8] + // => [1, 2, 3, 4, 6, 8]*/ setUnion (arr) => //could be a quicksort algorithm diff --git a/src/setcomplement.js b/src/setcomplement.js index 5ca0df9..5fe811c 100644 --- a/src/setcomplement.js +++ b/src/setcomplement.js @@ -1,17 +1,17 @@ export defautl function setComplement ({}) { -} -setComplement -Return the complement of two sets. +/*setComplement -const a = [1, 2, 3, 4] +Return the complement of two sets.*/ + +/*const a = [1, 2, 3, 4] const b = [2, 4, 6, 8] setComplement(a, b) -// => [6, 8] +// => [6, 8]*/ set.complement = (a, b) => { diff --git a/test/collatzconjecture_test.js b/test/collatzconjecture_test.js index b5fe25f..5daa86b 100644 --- a/test/collatzconjecture_test.js +++ b/test/collatzconjecture_test.js @@ -1,25 +1,19 @@ import { expect } from 'chai' -import collatzConjecture from '../src/collatzConjecture_test' +import collatzconjecture from '../src/collatzconjecture' -expect ('collatzConjecture_test()', function () { +//expect ('collatzConjecture_test()', function () { - describe('factorial_test()', function(){ + describe.only('collatzconjecture_test()', function() { it('should be a function', function(){ - expect.factorial_test.to.be.a('function') + expect.collatzconjecture.to.be.a('function') }) -describe('factorial_test()'{ - expect.factorial_test.to.be.a('function') -}) - - -it('If n is even, divide it by 2 ', function(){ - const Pali = isPalindrome({price: 100, amountGiven: 100}) - expect(change).to.be.an('object') - }) +//describe('collatzConjecture_test()'{ +// expect.factorial_test.to.be.a('function') +// }) diff --git a/test/factorial_test.js b/test/factorial_test.js index 169d040..c8f630f 100644 --- a/test/factorial_test.js +++ b/test/factorial_test.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import fizzBuzz from '../src/factorial_test' +import factorial from '../src/factorial' @@ -13,8 +13,8 @@ describe('factorial_test()', function(){ }) -it('returns a factorial )', function(){ - const change = factorial({return 1, if 0}) +it('returns a factorial', function(){ + const change = factorial({}) }) diff --git a/test/fibonacci_test.js b/test/fibonacci_test.js index 5830117..96aeb60 100644 --- a/test/fibonacci_test.js +++ b/test/fibonacci_test.js @@ -1,10 +1,10 @@ import { expect } from 'chai' -import fibonacci from '../src/fibonacci_test' +import fibonacci from '../src/fibonacci' describe('fibonacci()', function(){ it('should be a function()', function() { - expect((isPalindrome).to.be.a('function') + expect((fibonacci).to.be.a('function') }) //it('returns true when fibonacci = fibonacci', function(){ diff --git a/test/isPalindrome.js b/test/isPalindrome.js index b3f557b..8de9e6c 100644 --- a/test/isPalindrome.js +++ b/test/isPalindrome.js @@ -9,7 +9,7 @@ it('should be a function()', function() { }) it('returns true when isPalindrome = palindrome', function(){ - const Pali = isPalindrome({price: 100, amountGiven: 100}) + const Pali = isPalindrome(}) expect(change).to.be.an('object') }) }) diff --git a/test/setSymmetricalDifference_test.js b/test/setSymmetricalDifference_test.js index e0fbbfe..2ba4a21 100644 --- a/test/setSymmetricalDifference_test.js +++ b/test/setSymmetricalDifference_test.js @@ -1,2 +1,9 @@ import { expect } from 'chai' -import collatzConjecture from '../src/collatzConjecture_test' +import collatzConjecture from '../src/setSymmetricDifference' + +describe('setSymmetricDifference()', function(){ + + + it('should be a function', function(){ + expect(setSymmetricDifference).to.be.a('function') + }) diff --git a/test/setUnion_test.js b/test/setUnion_test.js index 7326516..0481efb 100644 --- a/test/setUnion_test.js +++ b/test/setUnion_test.js @@ -5,7 +5,4 @@ describe('setUnion', function () { it('should be a function'() { expect((setUnion).to.be.a('function'){ - - -it('should return ') - expect(()) +}