-
-
Notifications
You must be signed in to change notification settings - Fork 239
London | 25-ITP-Sep | KME Blair | Sprint 2 | Coursework #833
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| var str = `${str[0].toUpperCase()}${str.slice(1)}`; |
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.
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}`); |
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.
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 |
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.
To more precisely express a value is a string, we can enclose the value by a pair of double quotes. For example, "00".
Learners, PR Template
Self checklist
Changelist
done all sprint 2 coursework for Structuring and testing data Module
Questions
n/a