Manchester | 26-ITP-Sep | Rahana Suleiman | Sprint 2 | Complete Sprint 2 Coursework - #1563
rahanasuleiman8-ship-it wants to merge 18 commits into
Conversation
…writing the characters in my code
…imum, and num aand logged the value of num in my terminal
…gnment and explained the error it causes when attempted
…to get the correct value
…to get the correct value
…nsole.log is working without errors
-identify function calls, declarations, aand reassignments. -verify my code is working when I run console.log()
- document and explain the remainder(%) operator to calculate the remaining seconds after converting total seconds into full minutes. - provide a better name for the variable 'result' and experiment with different values of movieLength
- Explain the string methods for converting pence to pounds currency format
- Verify output of formatted currency string ('£3.99') via Node.js
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hey-hammad
left a comment
There was a problem hiding this comment.
Good work overall, few changes required. Thanks
| // Math.random() returns a random decimal between 0 and 1 | ||
| // Math.random() * maximum(100) returns a random decimal between 0 and 99.999 | ||
| // Math.floor() rounds up the decimal to the nearest whole number | ||
| // maximum and minimum calculates thee total output of the number(100) |
There was a problem hiding this comment.
good start, however the following expression can be explained more.
(maximum - minimum + 1))+ minimum
| //Explanation: Yes, my prediction was accurate. JavaScript threw a TypeError because '.slice()' is a string method | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
| const cardNumber = '4533787178994213'; | ||
| const last4Digits = cardNumber.slice(-4); |
There was a problem hiding this comment.
thats one way to do it, but can we do it without changing the original value?
| const 24hourClockTime = "20:53"; | ||
| // JavaScript variable names cannot start with a number. They must start with an alphabet(A-Z), an underscore(_), or a dollar sign($). JavaScript is also case sensitive so they have to use camelCase, PascalCase, among others. | ||
|
|
||
| const HourClockTime = "8:53pm"; |
There was a problem hiding this comment.
this fixes the issue, but are the variable names descriptive enough of the values they hold?
| //ANSWER: The expression movieLength % 60 uses the remainder (%) operator to calculate the number of seconds remaining that can't form a full seconds (8784 % 60 = 24 seconds) | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // ANSWER: The expression assigned to totalMinutes means division |
There was a problem hiding this comment.
the expression does include division, but please elaborate more what the whole expression is about.
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| // 2. const penceStringWithoutTrailingP: uses substring to remove the trailing "p" from "399p", leaving "399" | ||
| // 3. const paddedPenceNumberString: padStart() makes sure the string has at least 3 characters, adding "0" if required. If we have "5p" and we remove the "p" we would be left with "5", so padding it to 3 numbers will give us the output ("005") | ||
| // const pounds: removes everything except the final two digits, giving "3". |
There was a problem hiding this comment.
it does give 3, however please review the statement again. Think about what the code does and does it match your explanation?

Learners, PR Template
Self checklist
Task code
CYF-1039
Changelist
constreassignment errors usingletby reordering variable declarations.TypeErrorby converting numeric values before string slicing and fixed invalid variable identifiers starting with digits..substring(),.padStart(),.padEnd()) to convert pence to pounds currency format.