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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
},
"scripts": {
"test": "mocha --compilers js:babel-register"
},
"dependencies": {
"moment": "^2.18.1"
}
}
21 changes: 21 additions & 0 deletions src/date.js
Original file line number Diff line number Diff line change
@@ -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';
}
}
11 changes: 11 additions & 0 deletions src/disemvowelments.js
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions src/fibonacciBases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function fibonacciBases() {

}
16 changes: 15 additions & 1 deletion src/guessTheNumber.js
Original file line number Diff line number Diff line change
@@ -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!";
}
}

}
25 changes: 25 additions & 0 deletions src/json.js
Original file line number Diff line number Diff line change
@@ -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));
30 changes: 30 additions & 0 deletions src/lairotcaf.js
Original file line number Diff line number Diff line change
@@ -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));
3 changes: 3 additions & 0 deletions src/scrabBag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function scrabBag() {

}
10 changes: 10 additions & 0 deletions src/stringIndices.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
42 changes: 42 additions & 0 deletions src/stringPermutations.js
Original file line number Diff line number Diff line change
@@ -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<string.length; i++) {
// var char = string[i];
//
// if (string.indexOf(char) != i)
// continue;
//
// var remainingString = string.slice(0,i) + string.slice(i+1, string.length);
//
// for (var subPermutation of permut(remainingString))
// permutations.push(char + subPermutation)
// }
// return permutations;
// }
// }
15 changes: 15 additions & 0 deletions test/date_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect } from 'chai'
import date from '../src/date'

describe('date', () => {

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')
})

})
14 changes: 14 additions & 0 deletions test/disemvowelments_test.js
Original file line number Diff line number Diff line change
@@ -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')
})
})
6 changes: 6 additions & 0 deletions test/fibonacciBases_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// import { expect } from 'chai'
// import fibonacciBases from '../src/fibonacciBases.js'
//
// describe('stringIndices()', () => {
//
// }
10 changes: 8 additions & 2 deletions test/guessTheNumber_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
//
// })

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

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

})
Empty file added test/scrabBag_test.js
Empty file.
14 changes: 14 additions & 0 deletions test/stringIndices_test.js
Original file line number Diff line number Diff line change
@@ -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')
})

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

})
20 changes: 20 additions & 0 deletions test/utilities/sampleJson.json
Original file line number Diff line number Diff line change
@@ -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"
]
}