-
Notifications
You must be signed in to change notification settings - Fork 49
Ana's Work!!! (100%) #45
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
Open
Anasauce
wants to merge
8
commits into
GuildCrafts:master
Choose a base branch
from
Anasauce:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
855af9d
implements make change
Anasauce de495b4
implements fizzBuzz
Anasauce 992185d
implements isPalindrome
Anasauce 2875a7a
Merge pull request #1 from Anasauce/make-change
Anasauce be341b3
implemented factorial
Anasauce c4436b3
Merge pull request #2 from Anasauce/numeric
Anasauce 4838d7a
Update README.md
Anasauce 22aeb22
Update README.md
Anasauce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| const factorial = value => { | ||
|
|
||
| if( typeof value !== 'number' ){ | ||
| return 'value is not a number' | ||
| } | ||
|
|
||
| let factorialNumber = 1 | ||
| for(let index = 1; index <= value; index++){ | ||
| factorialNumber *= index | ||
| } | ||
|
|
||
| return factorialNumber | ||
|
|
||
| } | ||
|
|
||
| export default factorial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| export default function fizzBuzz(value) { | ||
| const returnArray = [] | ||
| for (let index = 1; index <= value; index++) { | ||
| let fizzBuzzyValue = '' | ||
|
|
||
| if(i % 3 === 0) { | ||
| fizzBuzzyValue = fizzBuzzyValue.concat('Fizz') | ||
| } | ||
| if(i % 5 === 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| fizzBuzzyValue = fizzBuzzyValue.concat('Buzz') | ||
| } | ||
| if(fizzBuzzyValue === '') { | ||
| fizzBuzzyValue = index | ||
| } | ||
| returnArray.push(fizzBuzzyValue) | ||
| } | ||
|
|
||
| return returnArray | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| const isPalidrome = string => { | ||
|
|
||
| if ( typeof string !== 'string') { | ||
| return "This is not a string" | ||
| } | ||
|
|
||
| let reversedString = '', | ||
| originalOnlyLetters = string.replace(/[\W_]/g, '').toLowerCase() | ||
|
|
||
| for ( let index = string.length - 1; index >= 0; index-- ) { | ||
| if ( string[index].search(/[\W_]/g) === -1 ) { | ||
| reversedString += string[index] | ||
| } | ||
| } | ||
|
|
||
| return originalOnlyLetters === reversedString.toLowerCase() | ||
| } | ||
|
|
||
| export default isPalidrome |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,39 @@ | ||
| export default function makeChange({price, amountGiven}) { | ||
| // your code here | ||
| const makeChange = ({price, amountGiven}) => { | ||
| let moneyBack = amountGiven - price | ||
| if ( moneyBack === NaN ) { | ||
| return 'no money given' | ||
| } | ||
| if ( moneyBack < 0 ) { | ||
| return 'You need to give more money!!!' | ||
| } | ||
|
|
||
| let change = { | ||
| quarters: 0, | ||
| dimes: 0, | ||
| nickels: 0, | ||
| pennies: 0, | ||
| } | ||
|
|
||
| while ( moneyBack > 24 ) { | ||
| change.quarters++ | ||
| moneyBack -= 25 | ||
| } | ||
|
|
||
| while ( moneyBack > 9 ) { | ||
| change.dimes++ | ||
| moneyBack -= 10 | ||
| } | ||
|
|
||
| while ( moneyBack > 4 ) { | ||
| change.nickels++ | ||
| moneyBack -= 5 | ||
| } | ||
|
|
||
| while ( moneyBack > 0 ) { | ||
| change.pennies++ | ||
| moneyBack -= 1 | ||
| } | ||
| return change | ||
| } | ||
|
|
||
| export default makeChange |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { expect } from 'chai' | ||
| import factorial from '../src/factorial' | ||
|
|
||
| describe('factorial()', () => { | ||
|
|
||
| it('should be a function', () => { | ||
| expect(factorial).to.be.a('function') | ||
| }) | ||
|
|
||
| it('returns the factorial of a number', () => { | ||
| expect(factorial(7)).to.equal(5040) | ||
| expect(factorial(4)).to.equal(24) | ||
| expect(factorial(5)).to.equal(120) | ||
| }) | ||
|
|
||
| it('only takes numbers', () => { | ||
| expect(factorial('blah blah')).to.equal('value is not a number') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { expect } from 'chai' | ||
| import fizzBuzz from '../src/fizzBuzz' | ||
|
|
||
| describe('fizzBuzz()', () => { | ||
|
|
||
| it('should be a function', () => { | ||
| expect(fizzBuzz).to.be.a('function') | ||
| }) | ||
|
|
||
| it('returns an array of numbers from 1 to value given', () => { | ||
| const returnArray = fizzBuzz(87) | ||
| expect(returnArray.length).to.equal(87) | ||
| }) | ||
|
|
||
| it('replaces mutiples of 3 with the string\'Fizz\', multiples of 5 with \'Buzz\', and multiples of 3 & 5 with \'FizzBuzz\'', () => { | ||
| const returnArray = fizzBuzz(64) | ||
|
|
||
| expect(returnArray[0]).to.eql(1) | ||
| expect(returnArray[2]).to.eql('Fizz') | ||
| expect(returnArray[5]).to.eql('Fizz') | ||
| expect(returnArray[4]).to.eql('Buzz') | ||
| expect(returnArray[14]).to.eql('FizzBuzz') | ||
| expect(returnArray[13]).to.eql(14) | ||
| expect(returnArray[29]).to.eql('FizzBuzz') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| 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 if value given is a isPalindrome, false if not', () => { | ||
| expect(isPalindrome('ana')).to.be.true | ||
|
|
||
| expect(isPalindrome('beyonce')).to.be.false | ||
| }) | ||
|
|
||
| it('Gets rid of punctiuation and white space to evaluate entire statement given', () => { | ||
| expect(isPalindrome('A man, a plan, a canal: Panama')).to.be.true | ||
|
|
||
| expect(isPalindrome('Hi my name is Ana!')).to.be.false | ||
| }) | ||
|
|
||
| it('Only take strings', () => { | ||
| expect(isPalindrome(300)).to.equal('This is not a string') | ||
|
|
||
| expect(isPalindrome(null)).to.equal('This is not a string') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iis not defined (I think you meantindex)