London | 26-Sep-ITP | Frumentius Tesfay | Sprint 3 | Coursework - #1589
Frumentius-Rev wants to merge 23 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hey, I removed one of the code comments but left the others. I’ll make sure to remove all unnecessary comments next time to keep the code tidy and professional. |
| // If I give the new variable a different name, I hope it should work :) | ||
|
|
||
| function capitalise(str) { | ||
| let newString = `${str[0].toUpperCase()}${str.slice(1)}`; |
There was a problem hiding this comment.
good analysis but can be variable name be something better ? a name that suggests what it holds
There was a problem hiding this comment.
oh, you’re right! I didn’t focus on using a descriptive name in the first place. I think capitalisedString is clearer and tidier. Thank you for pointing that out!
| return percentage; | ||
| } | ||
|
|
||
| console.log(convertToPercentage("26")); |
There was a problem hiding this comment.
Although the updated function is correct, could you check again what parameter says should be passed into the function ?
| console.log(a * b); | ||
| return a * b; | ||
| } | ||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
There was a problem hiding this comment.
Is there a possibility that the logs are being duplicated ?
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function toUpper(input) { | ||
| return input.replaceAll(" ", "_").toUpperCase(); |
There was a problem hiding this comment.
apart from uppercase, is this function perhaps adding something that does not exist in the input ?
There was a problem hiding this comment.
Yeah, I noticed that it also replaces the spaces with underscores besides converting to uppercase.
|
|
||
| // c) What is the return value of pad when it is called for the first time? | ||
| // =============> write your answer here | ||
| // 00 |
There was a problem hiding this comment.
even though the answer is correct, could it perhaps be a different return type ?
|
|
||
| // e) What is the return value of pad when it is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // 01 |
There was a problem hiding this comment.
even though the answer is correct, could it perhaps be a different return type ?
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Thanks for the fixes. capitalisedString is a clear name, and the quotes in c) and e) are right now.
A few things before this can be marked Complete:
2-mandatory-debug/0.jsstill prints the result twice. See my comment on line 6.1-key-errors/1.js: see my comment on line 32.time-format.jsd) and e) both say "Explain your answer". Lines 36 and 39 give only the value. Add a short reason to each.3-to-pounds.js: see my comment on line 24.2-mandatory-debug/2.js: see my comment on line 28.2-cases.js: see my comment on line 18.2-mandatory-debug/0.jsfails Prettier. Line 21 has spaces on an empty line. Right click in the file, choose Format Document, save and push. To format every time you save, follow the steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
Add the Needs Review label again once you've pushed.
| // =============> write your prediction here | ||
| // I believe the function will calculate 10 x 32 | ||
|
|
||
| function multiply(a, b) { |
There was a problem hiding this comment.
Lines 6 to 10 are the original code, and they still run. That is why the result prints twice. How did you stop the original code running in your other files?
There was a problem hiding this comment.
Prints once now. Good.
| return percentage; | ||
| } | ||
|
|
||
| console.log(convertToPercentage(26)); |
There was a problem hiding this comment.
The parameter is called decimalNumber. convertToPercentage(26) prints 2600%. Is 26 a decimal number? What would you pass to get 26%?
There was a problem hiding this comment.
0.7 gives 70%. Good.
| return `£${pounds}.${pence}`; | ||
| } | ||
|
|
||
| console.log(toPounds("1250p")); |
There was a problem hiding this comment.
Line 6 asks you to call the function a number of times, with different inputs. Line 24 calls it once. Try a few more, for example a short one and a long one.
There was a problem hiding this comment.
Good, three different inputs now.
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| const num = 103; |
There was a problem hiding this comment.
Is num on line 28 used now? Your function uses its own num parameter. If line 28 is not needed, remove it.
There was a problem hiding this comment.
Removed, good. A note for next time: two empty lines are left where it was, and Prettier flags them. With format on save turned on, Prettier removes them for you.
| // Use the MDN string documentation to help you find a solution | ||
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function toUpper(input) { |
There was a problem hiding this comment.
Function names should tell others what the function does. toUpper only describes part of it. If you use toUpperCase() as an inspiration, what would be a better name for this function?
There was a problem hiding this comment.
toUpperSnakeCase is the one.
9f31e1e to
6b8ec14
Compare
6b8ec14 to
9723adb
Compare
|
Thanks for the feedback! It helps me a lot and helps me see things from a different perspective. I’ve addressed all the comments and pushed the fixes. Everything should now be ready for review. 🌱 |
abdishakoor-dev
left a comment
There was a problem hiding this comment.
That's everything from the list, and d) and e) now explain why. Marking this Complete, well done.
I've left two small notes inline for next time. They don't need changes here.
| // If I give the new variable a different name, I hope it should work :) | ||
|
|
||
| function capitalise(str) { | ||
| let capitalisedString = `${str[0].toUpperCase()}${str.slice(1)}`; |
There was a problem hiding this comment.
For next time: capitalisedString is never given a new value, so it can be const instead of let. The same goes for BMI in 1-bmi.js line 18. Use let only when the value changes later.
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
|
|
||
| function toPounds(amount) { |
There was a problem hiding this comment.
For next time: amount could be any kind of amount. The input is a string of pence, like "50p". A name like penceString tells the reader that.
There was a problem hiding this comment.
Exactly! I will it in mind.

Learners, PR Template
Self checklist
Task code
CYF-1053
Changelist
I have demonstrated debugging and interpretation skills and completed the Sprint 3 requirements.