diff --git a/package.json b/package.json index 05eda2e..96391b4 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,8 @@ }, "scripts": { "test": "mocha --compilers js:babel-register" + }, + "dependencies": { + "moment": "^2.18.1" } } diff --git a/src/date.js b/src/date.js new file mode 100644 index 0000000..a884601 --- /dev/null +++ b/src/date.js @@ -0,0 +1,21 @@ +export default function date() { + var readlineSync = require('readline-sync'); + var year = yyyy; + var month = mm; + var day = dd; + var d = new Date(yyyy-mm-dd); + var dateEntry = readlineSync.question('What is the date?') + +if(year.length === 4, month.length === 2, day.length === 2) { + moment().format(YYYY-MM-DD); + // function makeDate(d) { + // let newYear = year <= 2017; + // let newDay = day <= 31 && day >= 1; + // let newMonth = month <=12 && day >= 1; + //Return Date Format + // return year + '-' + month + '-' + day; + } + else { + return 'error'; + } +} diff --git a/src/disemvowelments.js b/src/disemvowelments.js new file mode 100644 index 0000000..6c31114 --- /dev/null +++ b/src/disemvowelments.js @@ -0,0 +1,11 @@ +export default function disemvowelments() { + + var str = 'i am groot' + var arr = str.split('') + + const correctArray = arr.filter(function(element){ + const vowels = ['a','e','i','o','u',' '] + return !vowels.includes(element); + }).join('') + return correctArray; +} diff --git a/src/fibonacciBases.js b/src/fibonacciBases.js new file mode 100644 index 0000000..c05db8b --- /dev/null +++ b/src/fibonacciBases.js @@ -0,0 +1,3 @@ +export default function fibonacciBases() { + +} diff --git a/src/guessTheNumber.js b/src/guessTheNumber.js index 3cc49d8..575880c 100644 --- a/src/guessTheNumber.js +++ b/src/guessTheNumber.js @@ -1,3 +1,17 @@ export default function guessTheNumber() { - // your code here + var readlineSync = require('readline-sync'); + var userGuess = readlineSync.question('What is my number?') + var randomSelect = Math.floor(Math.random() * 100) + 1; + + if(userGuess < randomSelect) { + return "You're too low."; + } else { + if(userGuess > randomSelect){ + return "You're too high."; + } + else { + return "You win!"; + } + } + } diff --git a/src/json.js b/src/json.js new file mode 100644 index 0000000..9ba0dd7 --- /dev/null +++ b/src/json.js @@ -0,0 +1,25 @@ +export default function json(sampleJson) { + if(sampleJson instanceof Object) { + for(let key in sampleJson) { + if(sampleJson[key] === '4chan') { + return key; + } + else if(sampleJson[key] instanceof Object) { + for(let index in sampleJson[key]) { + if(sampleJson[key][index] === '4chan') { + return key+' -> '+index; + } + else if(sampleJson[key][index] instanceof Object) { + for(let value in sampleJson[key][index]) { + if(sampleJson[key][index][value] === '4chan') { + return key+' -> '+index+' -> '+value; + } + } + } + } + } + } + } +} +// var blah = require('../test/utilities/sampleJson.json'); +// console.log(json(blah)); diff --git a/src/lairotcaf.js b/src/lairotcaf.js new file mode 100644 index 0000000..3cba052 --- /dev/null +++ b/src/lairotcaf.js @@ -0,0 +1,30 @@ +export default function lairotcaf(number) { + + let product = 1; + for (var i = 1; product < number; i++) { + + product = product * i; + + if(product === number) { + return i + "!"; + } else { + return 'NONE'; + } + return i - 1; +} +} + // let product = 1; + // + // for (var i = 1; product < number; i++) { + // while (1 * i++) { + // array[i]; + // i.pop(); + // if (i * i++ === product) { + // return i.pop() + '!'; + // } else { + // return 'NONE'; + // } + // } + // } + // return lairotcaf(number(720)); + // return lairotcaf(number(37)); diff --git a/src/scrabBag.js b/src/scrabBag.js new file mode 100644 index 0000000..eedd0c6 --- /dev/null +++ b/src/scrabBag.js @@ -0,0 +1,3 @@ +export default function scrabBag() { + +} diff --git a/src/stringIndices.js b/src/stringIndices.js new file mode 100644 index 0000000..3067a4e --- /dev/null +++ b/src/stringIndices.js @@ -0,0 +1,10 @@ +export default function stringIndices() { + var str = "Catch me outside, how about that?"; + var n = strIndexOf; + + if(n === " " && n <= 0) { + return " "; + } else { + return n.strIndexOf(str); + } +} diff --git a/src/stringPermutations.js b/src/stringPermutations.js new file mode 100644 index 0000000..a257ab3 --- /dev/null +++ b/src/stringPermutations.js @@ -0,0 +1,42 @@ +export default function stringPermutations() { + const permutation = require('string-permutation') + + // permutation('bra', 3) + permutation('bra', {minSize: 3, maxSize: 3, recursive: true}) + +} + + + + + + + + + + + + + + + + +// function permut(string) { +// if (string.length < 2) +// return string; +// var permutations = []; +// +// for (var i=0; i { + + it('should be a function', function(){ + expect(date).to.be.a('function') + }) + + it('should return date in a string', function(){ + var d = new Date; + expect(date).to.be.a('date') + }) + +}) diff --git a/test/disemvowelments_test.js b/test/disemvowelments_test.js new file mode 100644 index 0000000..4920164 --- /dev/null +++ b/test/disemvowelments_test.js @@ -0,0 +1,14 @@ +import { expect } from 'chai' +import disemvowelments from '../src/disemvowelments.js' + +describe('disemvowelments(correctArray)', () => { + + it('should be a function', function(){ + expect(disemvowelments).to.be.a('function') + }) + + it('should return a string', function(){ + const element = 'i am groot' + expect(disemvowelments(element)).to.be.a('string') + }) +}) diff --git a/test/fibonacciBases_test.js b/test/fibonacciBases_test.js new file mode 100644 index 0000000..09b90e1 --- /dev/null +++ b/test/fibonacciBases_test.js @@ -0,0 +1,6 @@ +// import { expect } from 'chai' +// import fibonacciBases from '../src/fibonacciBases.js' +// +// describe('stringIndices()', () => { +// +// } diff --git a/test/guessTheNumber_test.js b/test/guessTheNumber_test.js index 2097b65..912d56d 100644 --- a/test/guessTheNumber_test.js +++ b/test/guessTheNumber_test.js @@ -3,6 +3,12 @@ import guessTheNumber from '../src/guessTheNumber' describe('guessTheNumber()', () => { - // Your tests here... - + it('should be a function', function(){ + expect(guessTheNumber).to.be.a('function') + }) + + // it('randomly selects a number' (1-100), function(){ + // + // }) + }) diff --git a/test/json_test.js b/test/json_test.js new file mode 100644 index 0000000..8a851ad --- /dev/null +++ b/test/json_test.js @@ -0,0 +1,15 @@ +import { expect } from 'chai' +import json from '../src/json' +import sampleJson from '../test/utilities/sampleJson' + +describe('json', () => { + + it('should be a function', function(){ + expect(json).to.be.a('function') + }) + + it('should return a string', function(){ + expect(json(sampleJson)).to.be.a('string') + }) + +}) diff --git a/test/lairotcaf_test.js b/test/lairotcaf_test.js new file mode 100644 index 0000000..0a45b11 --- /dev/null +++ b/test/lairotcaf_test.js @@ -0,0 +1,26 @@ +import { expect } from 'chai' +import lairotcaf from '../src/lairotcaf' + +describe('lairotcaf', () => { + + it('should be a function', function(){ + expect(lairotcaf).to.be.a('function') + }) + + it('should return the notation', function(){ + expect(lairotcaf(720)).to.be.a('string', '6!') + }) + + it('should return the notation', function(){ + expect(lairotcaf(37)).to.be.a('string', 'NONE') + }) + + // it('720 should return 6!', function() { + // expect('720').to.return('6!') + // }) + // + // it('37 should return NONE', function() { + // expect('37').to.return('NONE') + // }) + +}) diff --git a/test/scrabBag_test.js b/test/scrabBag_test.js new file mode 100644 index 0000000..e69de29 diff --git a/test/stringIndices_test.js b/test/stringIndices_test.js new file mode 100644 index 0000000..2c94971 --- /dev/null +++ b/test/stringIndices_test.js @@ -0,0 +1,14 @@ +import { expect } from 'chai' +import stringIndices from '../src/stringIndices.js' + +describe('stringIndices()', () => { + + it('should be a function', function(){ + expect(stringIndices).to.be.a('function') + }) + + it('should return a string', function(){ + expect(stringIndices(str)).to.be.a('string') + }) + +}) diff --git a/test/stringPermutations_test.js b/test/stringPermutations_test.js new file mode 100644 index 0000000..27c90c0 --- /dev/null +++ b/test/stringPermutations_test.js @@ -0,0 +1,14 @@ +import { expect } from 'chai' +import stringPermutations from '../src/stringPermutations' + +describe('stringPermutations', () => { + + it('should be a function', function(){ + expect(stringPermutations).to.be.a('function') + }) + + it('should return an array', function(){ + expect(stringPermutations('bra')).to.be.a('permutation') + }) + +}) diff --git a/test/utilities/sampleJson.json b/test/utilities/sampleJson.json new file mode 100644 index 0000000..e90293f --- /dev/null +++ b/test/utilities/sampleJson.json @@ -0,0 +1,20 @@ +{ + "name": "William Shakespeare", + "dead" : true, + "works" : [ + { + "name" : "Romeo and Juliet", + "published" : 1591, + "isAwesome" : true + }, + { + "name" : "Richard III", + "published" : 1592, + "isAwesome" : false + } + ], + "favoriteSites" : [ + "tumblr", + "4chan" + ] +}