London | 26-ITP-Sep | Alan Mak | Sprint 2 | Coursework - #1570
AlanGit-debug2604 wants to merge 9 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Your 3-paths.js works for any file name, because you used lastIndexOf for ext too. Every file runs with no errors.
Some answers are missing or need another look before I can mark this Complete:
-
1-key-exercises/1-count.jshas no answer yet. Describe what line 3 is doing, and what=does there. -
1-key-exercises/4-random.jsline 16: say whatnumis at the end. See my comment. -
2-mandatory-errors/2.js,3.jsand4.js: add the name of the error.2.jsand3.jsneed a little more too. See my comments. -
Delete the old code you commented out:
1.jslines 6 and 7,2.jslines 8 and 9,4.jslines 1 and 2, and1-percentage-change.jsline 5. Git keeps the old version for you. Keep your explanations. -
3-mandatory-interpret/1-percentage-change.js: the line numbers in a) to d), and answer e). See my comments. -
3-mandatory-interpret/2-time-format.jsanswer f): try more values. See my comment. -
3-mandatory-interpret/3-to-pounds.jsline 17. See my comment. -
Formatting. "My changes follow the style guide" is on your checklist, and consistent formatting is part of it. The tool that does it is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer only sees the changes you meant to make. At the moment 12 of your 13 files fail that check.
Your files also have Windows line endings. So GitHub shows every line as changed, even lines you did not touch. Prettier fixes this too.
Prettier comes with the CYF extension pack from onboarding. If you are not sure you have it, open VS Code, go to Extensions, and search for CodeYourFuture Extension Pack: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack
Then open each file you changed, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save, commit and push. To format every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
Add the Needs Review label again once you have pushed.
| // The value inside Math.floor() is its argument. The return value of this argument is expression within the yellow parenthesis. | ||
| // The whole expression of variable "num" is that a float generated by method Math.random() is multiplied by return value of the range specified by value between declared variable by key word constant. | ||
| // The method Math.floor() then return greatest integer of the value of this product. | ||
| // And finally plus the value of minimum variable declared. |
There was a problem hiding this comment.
Your steps are in the right order. Now finish with what num is. What is the smallest value it can be? What is the largest? Run the file a few times to check.
There was a problem hiding this comment.
num is a random integer between maximum and minimum inclusive.
The smallest value of 'num' can be 1
|
|
||
| //console.log(`I was born in ${cityOfBirth}`); | ||
| //const cityOfBirth = "Bolton"; | ||
| //The error is that the variable should be declared as a constant before it is used in the console.log statement. |
There was a problem hiding this comment.
The order is the problem, you are right. Does it need to be a constant, though? Would line 4 still work with let instead of const?
The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one is this?
There was a problem hiding this comment.
This is a ReferenceError.
In this code, the key word does not need to be constant, it can be let - if this is the case the variable city0fBirth can be reassigned in other lines - instead of constant (which cannot reassign variable).
| // Consider: Why does it give this error? Is this what I predicted? If not, what's different? | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
| // Expectation about the error : cardNumber is assigned a number value, a .slice function does not work on number | ||
| // The constant last4Digits should be assigned to a String (cardNumber) to perform .slice function. |
There was a problem hiding this comment.
Your prediction is clear. What happened when you ran it? Did it match your prediction?
The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one did you get?
| const 24hourClockTime = "20:53"; | ||
| // const 12HourClockTime = "8:53pm"; | ||
| // const 24hourClockTime = "20:53"; | ||
| // An identifier cannot start with a numberical value |
There was a problem hiding this comment.
Right reason. The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one is this?
| // Read the code and then answer the questions below | ||
|
|
||
| // a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
| // There are five function calls in this code in lines 4, 5, and 10 |
There was a problem hiding this comment.
Your answers use the line numbers of the original file. Your file has two extra lines now. The fixed line is on line 7, and console.log is on line 12. Delete line 5 and the empty line after it. Then check your line numbers in a) to d) again.
| // On lines 7 and 8, variables priceDifference and percentageChange are declared by const. | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| // To remove comma as a punctuation and space such that the string is ready turn into a number by method Number. No newline at end of file |
There was a problem hiding this comment.
Does this remove spaces too? Look at the first argument of replaceAll.
| // The variable result represents length of movie in H:M:S format. A better variable name can be movieLength_HMS | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // A value of movieLength 3661 will return a result of 1:1:1 where the place value for second does not conforms with leading zero time format. No newline at end of file |
There was a problem hiding this comment.
Good, the missing zeros are one problem. Now try -90 and 90.5. What does each one print? Would you show a time that way?
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); // declares variable for pence. Argument -2 of .substring method returns the last two characters. |
There was a problem hiding this comment.
The argument here is paddedPenceNumberString.length - 2, not -2. What number is that for "399"?

Alan Mak, PR Template
Self checklist
CYF-1039
Changelist
Work done in files in coursework, namely in folders:
1-key-exercises
2-mandatory-errors
3-mandatory-interpret and
4-stretch-explore