generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 239
West Midlands | ITP-Sept-25 | Mustaf Asani | Sprint 3 | Coursework/sprint 3 implement and rewrite #795
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
asaniDev
wants to merge
19
commits into
CodeYourFuture:main
Choose a base branch
from
asaniDev:coursework/sprint-3-implement-and-rewrite
base: main
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
West Midlands | ITP-Sept-25 | Mustaf Asani | Sprint 3 | Coursework/sprint 3 implement and rewrite #795
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
26fd354
changed the name of the string in the function
asaniDev 5ab6322
removed line 10 and passed function to console
asaniDev 0c7cc6f
corrected the error with the function
asaniDev cc216e1
added a return to the function
asaniDev 90013dc
moved the return command to the line below it
asaniDev f63f7cf
created a function that returns the bmi
asaniDev a02b0c5
created a function that converts a given string to snake case
asaniDev e097316
created a toPounds function to return a pounds and pence notation
asaniDev 742c228
answered all the questions in the exercise
asaniDev 0d5ad45
wrote tests for any edge cases and fixed resulting bugs
asaniDev 2038048
made a function for angle types and added tests for all angles
asaniDev 7daf16b
added tests for most fraction types and conditions for them as well
asaniDev dfebb97
added conditions for all ranks in a deck of cards and tests for them
asaniDev 6865348
added jest tests for all angle types
asaniDev 43d650c
added jest tests for different card values
asaniDev 3ca95c6
took away comment on line 30
asaniDev c56bd67
revert multiple commits that were from sprint 2
asaniDev 2765c49
added tests for multiple samples, removed a test for ace of spades, c…
asaniDev 035e27e
removed check for ace of spades, adjusted rank to give the full value…
asaniDev 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| //we should have an error showing that str already exists so we cannot declare it again inside the function. | ||
|
|
||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
| //function capitalise(str) { | ||
| // let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| // return str; | ||
| //} | ||
|
|
||
| //console.log(capitalise("cat")); | ||
|
|
||
| // =============> write your explanation here | ||
| //str has been passed down as a parameter so we cannot declare it again. we would need to declare a different variable name. | ||
| // =============> write your new code here | ||
| function capitalise(str) { | ||
| let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return capitalisedStr; | ||
| } | ||
|
|
||
| console.log(capitalise("cat")); |
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 |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
|
|
||
| // Predict and explain first BEFORE you run any code... | ||
|
|
||
| // this function should square any number but instead we're going to get an error | ||
|
|
||
| // =============> write your prediction of the error here | ||
| //it will throw an error for use of a primitive value instead of a variable. | ||
|
|
||
| function square(3) { | ||
| return num * num; | ||
| } | ||
| //function square(3) { | ||
| // return num * num; | ||
| //} | ||
|
|
||
| // =============> write the error message here | ||
| // =============> write the error message here, SyntaxError: Unexpected number | ||
|
|
||
| // =============> explain this error message here | ||
|
|
||
| //this error message is becasue we cannot pass a direct value to a function when creating it but rather when we call it. Instead we need to give it a parameter that can then hold the value that we want to pass to the function. | ||
| // Finally, correct the code to fix the problem | ||
|
|
||
| // =============> write your new code here | ||
| function square(num) { | ||
| return num * num; | ||
| } | ||
|
|
||
|
|
||
| console.log(square(3)); |
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,14 +1,21 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| //line 7 will log the result of a * b, line 10 will throw an error since the function does not return anything so it will say The result of multiplying 10 and 32 is undefined. | ||
|
|
||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| } | ||
| //function multiply(a, b) { | ||
| // console.log(a * b); | ||
| //} | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
| //console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| //since the function does not return a value we get undefined passed back to the console. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| function multiply(a, b) { | ||
| return a * b; | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
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,13 +1,20 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // the console will show The sum of 10 and 32 is undefined, this is because the return command is before the calculation so the return has no value to bring back. | ||
|
|
||
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| } | ||
| //function sum(a, b) { | ||
| // return; | ||
| // a + b; | ||
| //} | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
| //console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| //the console will show The sum of 10 and 32 is undefined, this is because the return command is before the calculation so the return has no value to bring back. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| function sum(a, b) { | ||
| return a + b; | ||
| } | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There is an easier syntax to check if a number is negative.
And since you are using
Math.abs(), checking for negatives is optional.This function can be further simplified. If you are up to the challenge, go for a solution that uses at most one if-statement.
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.
removed the check for negative and took off the first if else block, not quite sure how to reduce it to one if statement without making risky assumptions. since the function only returns true for a proper fraction and false for everything else, would it be appropriate to have an if statement that checks for a proper fraction and else that gives false for any other scenario?