London | 26-ITP-May | Yonatan Teklemariam | Sprint 2 | Coursework#1379
Open
Yonatanteklemariam wants to merge 14 commits into
Open
London | 26-ITP-May | Yonatan Teklemariam | Sprint 2 | Coursework#1379Yonatanteklemariam wants to merge 14 commits into
Yonatanteklemariam wants to merge 14 commits into
Conversation
Renamed variable 'str' to 'result' to avoid redeclaration error.
Fixed variable declaration issue in convertToPercentage function and updated console log.
Commented out the incorrect code and added a note about the declaration error.
Corrected the function parameter and added comments explaining the error.
The multiply function now returns the product of a and b, fixing the undefined output issue.
Fixed the sum function to return the correct value of a + b.
Refactor getLastDigit function to accept a parameter and update comments for clarity.
Implement snakeCaseString function to convert strings to snake case and uppercase.
Implemented a function to convert pence to pounds format.
cjyuan
reviewed
Jun 27, 2026
cjyuan
left a comment
Contributor
There was a problem hiding this comment.
Most of the code looks good.
Comment on lines
22
to
+32
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| /* ===========> function convertToPercentage(decimalNumber) { | ||
| let decimalNum = 0.5; | ||
| const percentage = `${decimalNum * 100}%`; | ||
|
|
||
|
|
||
| return percentage; | ||
| } | ||
| const result = convertToPercentage(); | ||
| console.log(result); | ||
| */ |
Contributor
There was a problem hiding this comment.
You get rid of the syntax error but the function still does not work quite correctly.
I expect convertToPercentage(0.1) to return "10%", but it returns "50%" instead.
Author
There was a problem hiding this comment.
yes i worked it out as well and it did the same because decimalNumber argument has already been defined inside the function as 0.5 and for that matter, it returned 50%. but here i've corrected the function and can return any decimal number passed through it as argument
Refactor convertToPercentage function to avoid redeclaration and return correct percentage.
Contributor
|
Changes look good. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Learners, PR Template
Self checklist
Changelist
debugged the code and corrected the function along with the parameters
Questions