Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numbers solved #46

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
88 changes: 0 additions & 88 deletions README.md

This file was deleted.

Empty file modified package.json
100644 → 100755
Empty file.
59 changes: 28 additions & 31 deletions src/__tests__/arrays.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
describe('getNthElement', () => {
const array = ['cat', 'dog', 'elephant', 'fox'];

xit('returns the element at the given position', () => {
it('returns the element at the given position', () => {
expect(getNthElement(0, array)).toEqual('cat');
expect(getNthElement(2, array)).toEqual('elephant');
expect(getNthElement(3, array)).toEqual('fox');
Expand All @@ -32,21 +32,21 @@ describe('getNthElement', () => {
});

describe('arrayToCSVString', () => {
xit('returns the array elements as a comma-seperated string', () => {
it('returns the array elements as a comma-seperated string', () => {
expect(arrayToCSVString(['a', 'b', 'c', 'd'])).toEqual('a,b,c,d');
expect(arrayToCSVString([1, 2, 3, 4, 5])).toEqual('1,2,3,4,5');
});
});

describe('csvStringToArray', () => {
xit('converts the csv string as an array', () => {
it('converts the csv string as an array', () => {
expect(csvStringToArray('a,b,c,d')).toEqual(['a', 'b', 'c', 'd']);
expect(csvStringToArray('1,2,3,4,5')).toEqual(['1', '2', '3', '4', '5']);
});
});

describe('addToArray', () => {
xit('adds the item to the end of the array', () => {
it('adds the item to the end of the array', () => {
const array = [];
const array2 = [1, 2, 3];

Expand All @@ -59,7 +59,7 @@ describe('addToArray', () => {
});

describe('addToArray2', () => {
xit('returns a new array with the value appended', () => {
it('returns a new array with the value appended', () => {
const array = ['a', 'b', 'c'];
const array2 = [1, 2, 3];

Expand All @@ -72,26 +72,26 @@ describe('addToArray2', () => {
});

describe('removeNthElement', () => {
xit('removes the element at position n', () => {
it('removes the element at position n', () => {
const array = ['ant', 'bison', 'cockerel', 'duck', 'elephant'];
removeNthElement(2, array);
expect(array).toEqual(['ant', 'bison', 'duck', 'elephant']);

const arrayTwo = ['thing 1', 'thing 2', 'thing 3', 'thing 4', 'thing 5'];
removeNthElement(0, arrayTwo);
expect(arrayTwo).toEqual(['thing 2', 'thing 3', 'thing 4', 'thing 5']);
});
});

describe('numbersToStrings', () => {
xit('converts every number in the array to a string', () => {
it('converts every number in the array to a string', () => {
expect(numbersToStrings([1, 2, 3])).toEqual(['1', '2', '3']);
expect(numbersToStrings([7, 8, 9])).toEqual(['7', '8', '9']);
});
});

describe('uppercaseWordsInArray', () => {
xit('makes every string in the array uppercase', () => {
it('makes every string in the array uppercase', () => {
expect(uppercaseWordsInArray(['cat', 'mouse', 'banana'])).toEqual([
'CAT',
'MOUSE',
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('reverseWordsInArray', () => {
});

describe('onlyEven', () => {
xit('filters the array and only returns even numbers', () => {
it('filters the array and only returns even numbers', () => {
expect(onlyEven([1, 2, 3, 4, 5, 6, 7, 8])).toEqual([2, 4, 6, 8]);
expect(onlyEven([8, 9, 10, 11, 12, 13, 14, 15])).toEqual([8, 10, 12, 14]);
});
Expand All @@ -139,7 +139,7 @@ describe('removeNthElement2', () => {
});

describe('elementsStartingWithAVowel', () => {
xit('returns elements starting with a vowel', () => {
it('returns elements starting with a vowel', () => {
expect(
elementsStartingWithAVowel([
'apple',
Expand Down Expand Up @@ -170,16 +170,13 @@ describe('elementsStartingWithAVowel', () => {
'zupple'
])
).toEqual(['apple', 'epple', 'ipple', 'opple', 'upple']);
expect(
elementsStartingWithAVowel([
'aaaa',
'bbbb',
'eeee',
])
).toEqual(['aaaa', 'eeee']);
expect(elementsStartingWithAVowel(['aaaa', 'bbbb', 'eeee'])).toEqual([
'aaaa',
'eeee'
]);
});

xit('is case insensitive', () => {
it('is case insensitive', () => {
expect(
elementsStartingWithAVowel([
'Apple',
Expand Down Expand Up @@ -210,18 +207,15 @@ describe('elementsStartingWithAVowel', () => {
'Zupple'
])
).toEqual(['Apple', 'Epple', 'Ipple', 'Opple', 'Upple']);
expect(
elementsStartingWithAVowel([
'Aaaa',
'Bbbb',
'Eeee',
])
).toEqual(['Aaaa', 'Eeee']);
expect(elementsStartingWithAVowel(['Aaaa', 'Bbbb', 'Eeee'])).toEqual([
'Aaaa',
'Eeee'
]);
});
});

describe('removeSpaces', () => {
xit('returns the string with the space characters removed', () => {
it('returns the string with the space characters removed', () => {
expect(removeSpaces('this string has spaces')).toEqual(
'thisstringhasspaces'
);
Expand All @@ -232,7 +226,7 @@ describe('removeSpaces', () => {
});

describe('sumNumbers', () => {
xit('returns the sum of the numbers in the array', () => {
it('returns the sum of the numbers in the array', () => {
expect(sumNumbers([1, 3, 5, 6, 2, 8])).toEqual(25);
expect(sumNumbers([1, 3, 5])).toEqual(9);
});
Expand All @@ -243,8 +237,11 @@ describe('sortByLastLetter', () => {
expect(
sortByLastLetter(['Lannister', 'Stark', 'Greyjoy', 'Targaryen'])
).toEqual(['Stark', 'Targaryen', 'Lannister', 'Greyjoy']);
expect(
sortByLastLetter(['Mo', 'Romy', 'Miguel', 'Martyna'])
).toEqual(['Martyna', 'Miguel', 'Mo', 'Romy']);
expect(sortByLastLetter(['Mo', 'Romy', 'Miguel', 'Martyna'])).toEqual([
'Martyna',
'Miguel',
'Mo',
'Romy'
]);
});
});
30 changes: 15 additions & 15 deletions src/__tests__/booleans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const {
} = require('../booleans');

describe('negate', () => {
xit('returns the opposite of the passed boolean value', () => {
it('returns the opposite of the passed boolean value', () => {
expect(negate(true)).toBe(false);
expect(negate(false)).toBe(true);
});
});

describe('both', () => {
xit('returns true if both of the given booleans are true', () => {
it('returns true if both of the given booleans are true', () => {
expect(both(true, true)).toBe(true);
expect(both(true, false)).toBe(false);
expect(both(false, true)).toBe(false);
Expand All @@ -33,7 +33,7 @@ describe('both', () => {
});

describe('either', () => {
xit('returns true if at least one of the given booleans are true', () => {
it('returns true if at least one of the given booleans are true', () => {
expect(either(true, true)).toBe(true);
expect(either(true, false)).toBe(true);
expect(either(false, true)).toBe(true);
Expand All @@ -42,7 +42,7 @@ describe('either', () => {
});

describe('none', () => {
xit('returns true if neither of the given booleans are true', () => {
it('returns true if neither of the given booleans are true', () => {
expect(none(true, true)).toBe(false);
expect(none(true, false)).toBe(false);
expect(none(false, true)).toBe(false);
Expand All @@ -51,7 +51,7 @@ describe('none', () => {
});

describe('one', () => {
xit('returns true if exactly one of the given booleans are true', () => {
it('returns true if exactly one of the given booleans are true', () => {
expect(one(true, true)).toBe(false);
expect(one(true, false)).toBe(true);
expect(one(false, true)).toBe(true);
Expand All @@ -60,7 +60,7 @@ describe('one', () => {
});

describe('truthiness', () => {
xit('returns the truthiness of the given value', () => {
it('returns the truthiness of the given value', () => {
expect(truthiness('')).toBe(false);
expect(truthiness('dbbd')).toBe(true);
expect(truthiness(0)).toBe(false);
Expand All @@ -74,7 +74,7 @@ describe('truthiness', () => {
});

describe('isEqual', () => {
xit('returns whether the two values are equal', () => {
it('returns whether the two values are equal', () => {
expect(isEqual(true, false)).toBe(false);
expect(isEqual(true, true)).toBe(true);
expect(isEqual('true', 'true')).toBe(true);
Expand All @@ -86,7 +86,7 @@ describe('isEqual', () => {
});

describe('isGreaterThan', () => {
xit('returns true if the first number is strictly greater than the second', () => {
it('returns true if the first number is strictly greater than the second', () => {
expect(isGreaterThan(1, 2)).toBe(false);
expect(isGreaterThan(3, 2)).toBe(true);
expect(isGreaterThan(4, 4)).toBe(false);
Expand All @@ -98,7 +98,7 @@ describe('isGreaterThan', () => {
});

describe('isLessThanOrEqualTo', () => {
xit('returns true if the first number is less than or equal to the second', () => {
it('returns true if the first number is less than or equal to the second', () => {
expect(isLessThanOrEqualTo(1, 2)).toBe(true);
expect(isLessThanOrEqualTo(3, 2)).toBe(false);
expect(isLessThanOrEqualTo(4, 4)).toBe(true);
Expand All @@ -108,7 +108,7 @@ describe('isLessThanOrEqualTo', () => {
});

describe('isOdd', () => {
xit('returns whether the number is odd', () => {
it('returns whether the number is odd', () => {
expect(isOdd(5)).toBe(true);
expect(isOdd(6)).toBe(false);
expect(isOdd(7)).toBe(true);
Expand All @@ -117,7 +117,7 @@ describe('isOdd', () => {
});

describe('isEven', () => {
xit('returns whether the number is even', () => {
it('returns whether the number is even', () => {
expect(isEven(5)).toBe(false);
expect(isEven(6)).toBe(true);
expect(isEven(7)).toBe(false);
Expand All @@ -126,7 +126,7 @@ describe('isEven', () => {
});

describe('isSquare', () => {
xit('returns true if the number is a square', () => {
it('returns true if the number is a square', () => {
expect(isSquare(9)).toEqual(true);
expect(isSquare(4)).toEqual(true);
expect(isSquare(5)).toEqual(false);
Expand All @@ -136,7 +136,7 @@ describe('isSquare', () => {
});

describe('startsWith', () => {
xit('returns whether the given string starts with the given character', () => {
it('returns whether the given string starts with the given character', () => {
expect(startsWith('a', 'aardvark')).toBe(true);
expect(startsWith('c', 'aardvark')).toBe(false);
expect(startsWith('b', 'baardvark')).toBe(true);
Expand All @@ -146,15 +146,15 @@ describe('startsWith', () => {
});

describe('containsVowels', () => {
xit('returns whether the given string contains vowels', () => {
it('returns whether the given string contains vowels', () => {
expect(containsVowels('cat')).toBe(true);
expect(containsVowels('DOG')).toBe(true);
expect(containsVowels('why')).toBe(false);
});
});

describe('isLowerCase', () => {
xit('it returns true if the given string is lowercase', () => {
it('it returns true if the given string is lowercase', () => {
expect(isLowerCase('abc')).toBe(true);
expect(isLowerCase('abc213')).toBe(true);
expect(isLowerCase('Abc')).toBe(false);
Expand Down
Loading