-
-
Notifications
You must be signed in to change notification settings - Fork 545
London | 26-ITP-Sep | Abakar Souleyman | Sprint 3 | Coursework #1583
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
abmhts
wants to merge
25
commits into
CodeYourFuture:main
Choose a base branch
from
abmhts:coursework/sprint-3
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
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3bdfb60
Convert price strings to numbers before calculating
abmhts 15e3b83
explaining error msg and fix the code
abmhts a44bb25
Explaining the error, prediction, and fix
abmhts c5a6226
fix function square code error
abmhts 052c090
Added return statement to fix the error
abmhts d6eb93e
fix return statement
abmhts 5afd460
BMI calculation code
abmhts a379651
fix of get last digit function error
abmhts e9fda63
convert to UPPER_SNAKE_CASE
abmhts f0201dd
added function called toPounds
abmhts c4470d9
time-format
abmhts add8d2e
Delete Sprint-2/3-mandatory-interpret/1-percentage-change.js
abmhts 73113c5
Revert "Delete Sprint-2/3-mandatory-interpret/1-percentage-change.js"
abmhts fc9a860
Remove accidentally added file
abmhts 6501234
Restore Sprint-2 file
abmhts 65e5b19
Update- explaining the error, prediction, and fix
abmhts 1b143ad
update - explaining error msg and fix the code
abmhts 2583b44
Update 2- explaining error msg and fix the code
abmhts b124f10
update 2- Explaining the error, prediction, and fix
abmhts 286c2a2
update
abmhts ff0eee9
update - fix function square code error
abmhts 62e622c
Update - convert to UPPER_SNAKE_CASE
abmhts 60be8e2
Remove Prettier changes from 5-stretch exercise
abmhts 862d481
Applied Prettier
abmhts a4a378f
Merge branch 'coursework/sprint-3' of https://github.com/abmhts/Modul…
abmhts 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,19 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
|
|
||
| //- we expect a syntaxerror because "str" is already declared as function parameter and again as a variable within the same function scope. | ||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
| //"Error: SyntaxError: Identifier 'str' has already been declared" why: because "str" declared twice. | ||
|
|
||
| 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; | ||
| // } | ||
|
|
||
| // =============> write your explanation here | ||
| // Instead of storing the formatted string in a new variable and then returning it, I return the expression directly since the variable was only used once. | ||
| // =============> write your new code here | ||
| function capitalise(str) { | ||
| return `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| } | ||
| console.log(capitalise("abakar")); |
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,29 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Why will an error occur when this program runs? | ||
| //- variable name "decimalNumber" declared twice in the same function. one as function parameter and again as a const in the same function. | ||
| // =============> write your prediction here | ||
|
|
||
| //- SyntaxError because "decimalNumber" declared twice. | ||
| // Try playing computer with the example to work out what is going on | ||
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
| // function convertToPercentage(decimalNumber) { | ||
| // const decimalNumber= 0.5; | ||
| // const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
| // return percentage; | ||
| // } | ||
|
|
||
| console.log(decimalNumber); | ||
| // console.log(decimalNumber); | ||
|
|
||
| // =============> write your explanation here | ||
| // I removed the separate decimalNumber variable because the function already accepts decimalNumber as a parameter. I can now pass a number directly when calling the function, such as convertToPercentage(7). The function multiplies the value by 100 and appends % to return the percentage. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
|
|
||
| console.log(convertToPercentage(7)); |
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,25 @@ | ||
|
|
||
| // Predict and explain first BEFORE you run any code... | ||
|
|
||
| // this function should square any number but instead we're going to get an error | ||
| //we are giving a value for the input instead of name that can hold different values. | ||
|
|
||
| // =============> write your prediction of the error here | ||
| //syntaxerror related to the function input "(3)" | ||
|
|
||
| function square(3) { | ||
| return num * num; | ||
| } | ||
| // function square(3) { | ||
| // return num * num; | ||
| // } | ||
|
|
||
| // =============> write the error message here | ||
|
|
||
| // SyntaxError: Unexpected number | ||
| // =============> explain this error message here | ||
|
|
||
| // we gave a placeholder for the function instead of value that can't be changed. | ||
| // 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 | ||
| //- "a and b" are defined as parameters and receive 10 and 32. The function calculates and logs 320, but it doesn't return the value. Because there is no return, the function call evaluates to 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 | ||
| //- Added a return statement so the function returns the result to the function call. The console.log() is just printing 320 and function doesn't give 320 back and thats why "${multiply(10, 32)}" gets undefined. | ||
|
|
||
| // 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,21 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| //- return statement in this case stops before it can do the sum of a + b. | ||
|
|
||
| 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 | ||
| //- added a + b to return so function returns the sum. | ||
| // 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
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.
This answer is still empty. Your prediction on line 8 says SyntaxError. Was that right? Write the error name here.
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.
updated the error message.
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.
That's the one. Fixed.