Conversation
Added comments to explain variable declaration and assignment.
Updated the initials variable to dynamically generate initials from first, middle, and last names.
Corrected comments to clarify the purpose of line 3.
Added variables to extract directory and extension from filePath.
Updated comments to clarify the purpose of the random number generation and the evaluation order of expressions.
Changed 'const' to 'let' for age variable and reassigned it to 1.
Fix variable declaration order to enable correct logging.
Updated last4Digits assignment to convert cardNumber to a string before slicing.
Updated comments to provide answers to questions about the code.
Added comments to explain the purpose of each line in the program.
Clarified effects and return values of alert and prompt functions.
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Good start. initials and dir both come out right, and your answer to e) in 1-percentage-change.js is clear.
Some things to fix before I can mark it Complete:
-
2-mandatory-errors/3.jsstill stops with an error. See my comment on line 2. -
2-mandatory-errors/1.jsline 4 changes what the program does. See my comment. -
2-mandatory-errors/1.js,2.js,3.jsand4.js: the code is fixed, but no error is written down. The README asks you to explain each error. See my comment on2.js. -
1-key-exercises/4-random.js: one step is missing from your breakdown. -
3-mandatory-interpret/1-percentage-change.js: answers a) and b) need a little more. -
3-mandatory-interpret/2-time-format.js: answers c), d) and e) are only half done. -
3-mandatory-interpret/3-to-pounds.js: the breakdown stops at line 9. Lines 9 to 18 have no explanation yet. -
"My code is consistently formatted" is on the checklist. The tool that does it is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer sees only the changes you meant to make. Right now nine of your files fail that check.
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 do this on every 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 have pushed and I will take another look.
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
|
|
||
| const last4Digits = string(cardNumber).slice(-4); |
There was a problem hiding this comment.
Run node 3.js. It stops with a new error. Look at the capital letters. Is string the same as String?
There was a problem hiding this comment.
Fixed. It prints 4213 now.
Your prediction is on line 6. Now add the error name: SyntaxError, TypeError or ReferenceError? Was your prediction right?
| const age = 33; | ||
| age = age + 1; | ||
| let age = 33; | ||
| age = 1; |
There was a problem hiding this comment.
Line 1 says the goal. The age should go up by 1. With this line, what is age after line 4? Is that 34?
There was a problem hiding this comment.
Fixed. It prints 34 now. Good.
Now add the error. The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one was it here? And why did it happen?
| @@ -1,5 +1,5 @@ | |||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | |||
| // what's the error ? | |||
| // what's the error | |||
There was a problem hiding this comment.
Your fix works. But the question "what's the error?" has no answer yet. Put the original code back for a moment. Run it, and copy the exact message node prints. Then explain in your own words why it happens. Do the same in 1.js, 3.js and 4.js. In 3.js, also say if your prediction was right.
There was a problem hiding this comment.
The message is there now. Good. One more thing. Why does this error happen? Write it in your own words.
| // In this exercise, you will need to work out what num represents?It gives us a random number between 1-100 | ||
| // Try breaking down the expression and using documentation to explain what it means | ||
| //Math.random gives us a random number between 0-1 and the next parantecec returns 100 | ||
| //after that we multiple these two given values between 0-100 and the floor methode rounds down the given value |
There was a problem hiding this comment.
After Math.floor, the number is from 0 to 99. What does + minimum do next? What is the smallest num can be, and the biggest?
There was a problem hiding this comment.
Right, 1 to 100. Good.
| //Line 5 | ||
| //Number(...) | ||
| //Line 5 | ||
| //console.log |
There was a problem hiding this comment.
Your count of 5 is right. Which line is console.log on?
There was a problem hiding this comment.
console.log is not on line 9. Look again.
|
|
||
| // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? | ||
|
|
||
| //missing a comma between the two arguments. |
There was a problem hiding this comment.
The reason is right. The question also asks which line. And what error name did node print?
There was a problem hiding this comment.
Good. That is the one.
| // b) How many function calls are there?1 | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| //The % operator is called the remainder operator. |
There was a problem hiding this comment.
This explains % in general. What does movieLength % 60 mean in this program? It is 24 here. 24 what?
There was a problem hiding this comment.
Yes, 24 seconds. Good.
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean?This removes the seconds that don't make up a complete minute. |
There was a problem hiding this comment.
That is the first half. What does dividing by 60 give you after that?
There was a problem hiding this comment.
Right, 146 minutes.
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean?This removes the seconds that don't make up a complete minute. | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // e) What do you think the variable result represents? Can you think of a better name for this variable?creates a formatted representation of the movie's length in hours, minutes, and seconds. |
There was a problem hiding this comment.
Right. The question also asks for a better name. What would you call it?
| //const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| //const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters. | ||
| //const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); | ||
| //This line extracts the pounds part. |
There was a problem hiding this comment.
Line 27 and line 28 repeat the same code. Keep one. Then keep going. What do lines 14 to 16 give for pence? What does padEnd do there? And what does line 18 print?
There was a problem hiding this comment.
Your pence steps are right now, and £3.99 is correct.
Lines 27 and 28 still repeat the same code. Delete line 27.
Corrected the type conversion from 'string' to 'String' for proper functionality.
Fixed comment to clarify the error message.
Updated comments to clarify the random number generation process.
Updated comments to clarify error details and variable reassignment.
Updated comments for clarity and added explanations for variable meanings.
Updated comments to clarify the conversion process from pence to pounds.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Good progress. 3.js runs now, and your time-format answers c) and d) are right.
Still to do before I can mark this Complete:
2-mandatory-errors/1.js,3.jsand4.js: write down which error each file had, and why.2.jsneeds the reason too.3-mandatory-interpret/1-percentage-change.jsanswer a): check the line forconsole.log.3-mandatory-interpret/3-to-pounds.js: lines 27 and 28 repeat the same code.- Prettier: nine files still fail. Format each file you changed, then push. Format on save stops this from happening: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
See my comment on each line. Add the Needs Review label again once you have pushed.
| @@ -1,2 +1,2 @@ | |||
| const 12HourClockTime = "8:53pm"; | |||
| const 24hourClockTime = "20:53"; | |||
| const twelveHourClockTime = "8:53pm"; | |||
There was a problem hiding this comment.
Your fix runs. Now add the error.
The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one was it here? And why did it happen?

Learners, PR Template
Self checklist
Task code
CYF-1039
Changelist
Sprint 2 | Coursework/sprint 2
Questions