London | 25-ITP-Sep | KME Blair | Sprint 2 | Coursework#833
Closed
kohanman wants to merge 12 commits intoCodeYourFuture:mainfrom
Closed
London | 25-ITP-Sep | KME Blair | Sprint 2 | Coursework#833kohanman wants to merge 12 commits intoCodeYourFuture:mainfrom
kohanman wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Nov 8, 2025
|
|
||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| var str = `${str[0].toUpperCase()}${str.slice(1)}`; |
Contributor
There was a problem hiding this comment.
str (the parameter) works like a local variable.
Redeclaring str using var has no effect on str (Note: Redeclaring str using let or const is prohibited)
So
var str = `${str[0].toUpperCase()}${str.slice(1)}`;
is identical to
str = `${str[0].toUpperCase()}${str.slice(1)}`;
In general, avoid using var because it can make our code behave in unexpected ways (if not used properly); let and const are safer.
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
|
|
||
| console.log(`£${pounds}.${pence}`); |
Contributor
There was a problem hiding this comment.
The function is expected to return a string in pound format. Outputting the string to console is not the same as returning the string.
|
|
||
| // c) What is the return value of pad is called for the first time? | ||
| // =============> write your answer here | ||
| //00 |
Contributor
There was a problem hiding this comment.
To more precisely express a value is a string, we can enclose the value by a pair of double quotes. For example, "00".
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
done all sprint 2 coursework for Structuring and testing data Module
Questions
n/a