-
-
Notifications
You must be signed in to change notification settings - Fork 389
Cape Town | 25-ITP-May | Asanda Dunn | Sprint 2 | Coursework/sprint2 #1418
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?
Changes from all commits
c12f358
de229c5
30efd9d
3e834b4
ccc134b
62c7888
3f8ce08
3e2c324
c697a4d
4fd9db6
22907b2
cd16173
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,27 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // I don't think this will work because str is already an argument in the capitalise function | ||
| // so declaring it again is incorrect. Another thing is the variable str is being declared but the value assigned to | ||
| // it basically uses the str variable to interpolate the string | ||
|
|
||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
|
|
||
|
|
||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your explanation here// | ||
| // SyntaxError: Identifier 'str' has already been declared | ||
| // this is happening because the str variable already exist as an argument in this function | ||
| // =============> write your new code here | ||
|
|
||
| function capitalize(str){ | ||
| let car = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return car; | ||
| } | ||
| capitalize("hello") | ||
| console.log(capitalize("hello")) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,21 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
|
|
||
| // This function is not returning anything | ||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
|
|
||
| // This function is not returning anything. It does multiply the assigned values of a,b but it does not return the String with the | ||
| // as required on line 9 | ||
| // 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)}`); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,27 @@ | |
| // You will need to declare a function called toPounds with an appropriately named parameter. | ||
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
| function toPounds(penceString){ | ||
|
|
||
| const penceStringWithoutTrailingP = penceString.substring( | ||
| 0, | ||
| penceString.length - 1 | ||
| ); | ||
|
|
||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart( | ||
| 3, | ||
| "0" | ||
| ); | ||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
|
|
||
| const result = `£${pounds}.${pence}`; | ||
| return result | ||
|
Comment on lines
+27
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code is not properly formatted. Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good that you have installed prettier and know how to format code. The code you showed in the screenshot is not the the file I was referring to.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how the code looks like on my VSCode.
If you haven't enabled format on save, you would need to manually use the "Format document" option to apply the formatter to format the code. And if you have more than one formatters installed, you may need to choose a default formatter for the "format on save" to work properly. |
||
| } | ||
| console.log(toPounds("399p")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not complete the implementation of the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did complete the formatAs12HourClock(), maybe I did not commit the work done on that file. Please check again if you are able to see it from your end
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the implementation of this functio on GitHub. I also don't see the changes you said you made in You could click the "Files changed" tab on your PR on GitHub to see what files are changed on GitHub. That's also typically how the code reviewer views the changes in a PR. |




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.
return a * b;would be enough.The general syntax of the return statement is:
And the value of
expressionis returned.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.
Thank you, I have implemented the reommended changes