Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"mocha": "2.0.1"
},
"scripts": {
"build": "babel src -d lib",
"test": "mocha --compilers js:babel-register"
}
}
27 changes: 27 additions & 0 deletions src/FizzBuzz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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) => {
let 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")
}
}
23 changes: 23 additions & 0 deletions src/collatzconjecture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default function collatzconjecture({}) {



/*collatzConjecture(1)
// => [1]

collatzConjecture(7)
// => [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
}
}
}
26 changes: 26 additions & 0 deletions src/factorial.js
Original file line number Diff line number Diff line change
@@ -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;
}
25 changes: 25 additions & 0 deletions src/fibonacci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default function fibonnaci({}){

//npm test






fibonacci(10)
// => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]


fibonacci(num) => {
var x = 1, y = 0, temp;

while (num >= 0){
temp = x;
x = x + y;
y = temp;
num--;
}

return y;
}
35 changes: 35 additions & 0 deletions src/isPalindrome.js
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
28 changes: 28 additions & 0 deletions src/setIntersection.js
Original file line number Diff line number Diff line change
@@ -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 (let i = 0; i < arr.length - 1; i++) {
if (sorted_arr[i + 1] == sorted_arr[i]) {
results.push(sorted_arr[i]);
}
}

console.log(results);
33 changes: 33 additions & 0 deletions src/setSymmetricDifference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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]


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;
}
40 changes: 40 additions & 0 deletions src/setUnion.js
Original file line number Diff line number Diff line change
@@ -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;
}
*/
21 changes: 21 additions & 0 deletions src/setcomplement.js
Original file line number Diff line number Diff line change
@@ -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 = (a, b) => {
return process(a, b, function(freq) {
return freq === 1;
});
};
19 changes: 19 additions & 0 deletions test/collatzconjecture_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'chai'
import collatzconjecture from '../src/collatzconjecture'




//expect ('collatzConjecture_test()', function () {

describe.only('collatzconjecture_test()', function() {

it('should be a function', function(){
expect.collatzconjecture.to.be.a('function')
})


//describe('collatzConjecture_test()'{
// expect.factorial_test.to.be.a('function')
//
})
24 changes: 24 additions & 0 deletions test/factorial_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect } from 'chai'
import factorial from '../src/factorial'






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({})
})



it('returns factorial', function(){
expect(factorial({return undefined if < 0)}
})
22 changes: 22 additions & 0 deletions test/fibonacci_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from 'chai'
import fibonacci from '../src/fibonacci'

describe('fibonacci()', function(){

it('should be a function()', function() {
expect((fibonacci).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 )
})
})
19 changes: 19 additions & 0 deletions test/fizzBuzz_test.js
Original file line number Diff line number Diff line change
@@ -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})
21 changes: 21 additions & 0 deletions test/isPalindrome.js
Original file line number Diff line number Diff line change
@@ -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(})
expect(change).to.be.an('object')
})
})

it('returns false if isPalindrome is not a Palindrome,' function(){
expect(isPalindrome({})).to.deep.equal({

})
})
2 changes: 2 additions & 0 deletions test/makeChange_test.js
Original file line number Diff line number Diff line change
@@ -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')
})
Expand Down
Loading