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
31 changes: 28 additions & 3 deletions Fundamentals 5/caesar/caesar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
const caesar = function() {
const caesar = function (userInput, shiftNumber) {
let result = "";

}
for (let i = 0; i < userInput.length; i++) {
// check if shiftNumber is a negative number
if (shiftNumber < 0) {
shiftNumber = 26 + (shiftNumber % 26);
}

module.exports = caesar
// Uppercase letters
if (userInput.charCodeAt(i) >= 65 && userInput.charCodeAt(i) <= 90) {
const charCode = userInput.charCodeAt(i);
result += String.fromCharCode(((charCode - 65 + shiftNumber) % 26) + 65);

// Lowercase letters
} else if (userInput.charCodeAt(i) >= 97 && userInput.charCodeAt(i) <= 122) {
const charCode = userInput.charCodeAt(i);
result += String.fromCharCode(((charCode - 97 + shiftNumber) % 26) + 97);

// if it's not a letter
} else {
result += userInput.charAt(i);
}
}

return result;

};

module.exports = caesar;
12 changes: 6 additions & 6 deletions Fundamentals 5/caesar/caesar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ describe('caesar', function() {
it('works with single letters', function() {
expect(caesar('A', 1)).toEqual('B');
});
xit('works with words', function() {
it('works with words', function() {
expect(caesar('Aaa', 1)).toEqual('Bbb');
});
xit('works with phrases', function() {
it('works with phrases', function() {
expect(caesar('Hello, World!', 5)).toEqual('Mjqqt, Btwqi!');
});
xit('works with negative shift', function() {
it('works with negative shift', function() {
expect(caesar('Mjqqt, Btwqi!', -5)).toEqual('Hello, World!');
});
xit('wraps', function() {
it('wraps', function() {
expect(caesar('Z', 1)).toEqual('A');
});
xit('works with large shift factors', function() {
it('works with large shift factors', function() {
expect(caesar('Hello, World!', 75)).toEqual('Ebiil, Tloia!');
});
xit('works with large negative shift factors', function() {
it('works with large negative shift factors', function() {
expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!');
});
});
34 changes: 22 additions & 12 deletions Fundamentals 5/calculator/calculator.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
function add () {

function add (a, b) {
return a + b;
}

function subtract () {

function subtract (a, b) {
return a - b;
}

function sum () {

function sum (array) {
return array.reduce((total, num) => {
return total + num;
}, 0);
}

function multiply () {

function multiply (array) {
return array.reduce((total, num) => {
return total * num;
}, 1);
}

function power() {

function power(a, b) {
return a ** b;
}

function factorial() {

function factorial(n) {
if (n === 0 || n === 1) {
return 1;
}
for (let i = n-1; i >= 1; i--) {
n *= i;
}
return n;
}

module.exports = {
Expand Down
30 changes: 15 additions & 15 deletions Fundamentals 5/calculator/calculator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,73 @@ describe('add', function() {
expect(calculator.add(0,0)).toEqual(0);
});

xit('adds 2 and 2', function() {
it('adds 2 and 2', function() {
expect(calculator.add(2,2)).toEqual(4);
});

xit('adds positive numbers', function() {
it('adds positive numbers', function() {
expect(calculator.add(2,6)).toEqual(8);
});
});

describe('subtract', function() {
xit('subtracts numbers', function() {
it('subtracts numbers', function() {
expect(calculator.subtract(10,4)).toEqual(6);
});
});

describe('sum', function() {
xit('computes the sum of an empty array', function() {
it('computes the sum of an empty array', function() {
expect(calculator.sum([])).toEqual(0);
});

xit('computes the sum of an array of one number', function() {
it('computes the sum of an array of one number', function() {
expect(calculator.sum([7])).toEqual(7);
});

xit('computes the sum of an array of two numbers', function() {
it('computes the sum of an array of two numbers', function() {
expect(calculator.sum([7,11])).toEqual(18);
});

xit('computes the sum of an array of many numbers', function() {
it('computes the sum of an array of many numbers', function() {
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
});
});

describe('multiply', function() {
xit('multiplies two numbers', function() {
it('multiplies two numbers', function() {
expect(calculator.multiply([2,4])).toEqual(8);
});

xit('multiplies several numbers', function() {
it('multiplies several numbers', function() {
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
});
});

describe('power', function() {
xit('raises one number to the power of another number', function() {
it('raises one number to the power of another number', function() {
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
});
});

describe('factorial', function() {
xit('computes the factorial of 0', function() {
it('computes the factorial of 0', function() {
expect(calculator.factorial(0)).toEqual(1); // 0! = 1
});

xit('computes the factorial of 1', function() {
it('computes the factorial of 1', function() {
expect(calculator.factorial(1)).toEqual(1);
});

xit('computes the factorial of 2', function() {
it('computes the factorial of 2', function() {
expect(calculator.factorial(2)).toEqual(2);
});

xit('computes the factorial of 5', function() {
it('computes the factorial of 5', function() {
expect(calculator.factorial(5)).toEqual(120);
});

xit('computes the factorial of 10', function() {
it('computes the factorial of 10', function() {
expect(calculator.factorial(10)).toEqual(3628800);
});
});
13 changes: 11 additions & 2 deletions Fundamentals 5/fibonacci/fibonacci.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const fibonacci = function() {

const fibonacci = function(n) {
let array = [0, 1];

if (n > 0) {
for (let i = 2; i < n+1; i++) {
array.push(array[i-2] + array[i-1]);
}
return array[n];
} else {
return "OOPS";
}
}

module.exports = fibonacci
16 changes: 8 additions & 8 deletions Fundamentals 5/fibonacci/fibonacci.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ describe('fibonacci', function() {
it('works', function() {
expect(fibonacci(4)).toEqual(3);
});
xit('works', function() {
it('works', function() {
expect(fibonacci(6)).toEqual(8);
});
xit('works', function() {
it('works', function() {
expect(fibonacci(10)).toEqual(55);
});
xit('works', function() {
it('works', function() {
expect(fibonacci(15)).toEqual(610);
});
xit('works', function() {
it('works', function() {
expect(fibonacci(25)).toEqual(75025);
});
xit('doesn\'t accept negatives', function() {
it('doesn\'t accept negatives', function() {
expect(fibonacci(-25)).toEqual("OOPS");
});
xit('DOES accept strings', function() {
it('DOES accept strings', function() {
expect(fibonacci("1")).toEqual(1);
});
xit('DOES accept strings', function() {
it('DOES accept strings', function() {
expect(fibonacci("2")).toEqual(1);
});
xit('DOES accept strings', function() {
it('DOES accept strings', function() {
expect(fibonacci("8")).toEqual(21);
});
});
7 changes: 5 additions & 2 deletions Fundamentals 5/findTheOldest/findTheOldest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
let findTheOldest = function() {

let findTheOldest = function(array) {
array.sort((a, b) => {
return a.yearOfBirth - b.yearOfBirth;
});
return array[0];
}

module.exports = findTheOldest
Expand Down
9 changes: 6 additions & 3 deletions Fundamentals 5/getTheTitles/getTheTitles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const getTheTitles = function() {

const getTheTitles = function(array) {
const result = array.map(element => {
return element.title;
})
return result;
}

module.exports = getTheTitles;
module.exports = getTheTitles;
6 changes: 5 additions & 1 deletion Fundamentals 5/palindromes/palindromes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const palindromes = function() {
const palindromes = function(str) {
const punctuation = /[^A-Za-z0-9]/g;
const strLowNoPunct = str.toLowerCase().replace(punctuation, "");
const strReversed = strLowNoPunct.split('').reverse().join('');

return strLowNoPunct === strReversed;
}

module.exports = palindromes
10 changes: 5 additions & 5 deletions Fundamentals 5/palindromes/palindromes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ describe('palindromes', function() {
it('works with single words', function() {
expect(palindromes('racecar')).toEqual(true);
});
xit('works with punctuation ', function() {
it('works with punctuation ', function() {
expect(palindromes('racecar!')).toEqual(true);
});
xit('works with upper-case letters ', function() {
it('works with upper-case letters ', function() {
expect(palindromes('Racecar!')).toEqual(true);
});
xit('works with multiple words', function() {
it('works with multiple words', function() {
expect(palindromes('A car, a man, a maraca.')).toEqual(true);
});
xit('works with multiple words', function() {
it('works with multiple words', function() {
expect(palindromes('Animal loots foliated detail of stool lamina.')).toEqual(true);
});
xit('doesn\'t just always return true', function() {
it('doesn\'t just always return true', function() {
expect(palindromes('ZZZZ car, a man, a maraca.')).toEqual(false);
});

Expand Down
Binary file removed Pricing Plans/Individual A/Pricing-Plans--Boozt.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Pricing Plans/Mockup-to-HTML.jpg
Binary file not shown.
Binary file removed Pricing Plans/Mockup.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Pricing Plans/Pricing Plans B/Pricing-Plans--B.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Pricing Plans/Pricing Plans C/Pricing-Plans--C.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Pricing Plans/Pricing Plans D/Pricing-Plans--D.png
Binary file not shown.
36 changes: 0 additions & 36 deletions Pricing Plans/README.md

This file was deleted.

Binary file removed Pricing Plans/images/Builder-Widgets-Pro.jpg
Binary file not shown.
Binary file removed Pricing Plans/images/Site-Shield-Standard.jpg
Binary file not shown.
Binary file removed Pricing Plans/images/Theme-Setup-Service.jpg
Diff not rendered.
Loading