Birmingham | 26-ITP-May | Tobias Amaechina | Sprint 1 | coursework#1369
Birmingham | 26-ITP-May | Tobias Amaechina | Sprint 1 | coursework#1369Tobias-Amaechina wants to merge 48 commits into
Conversation
…o I used let keyword to declare the variable
…r instead of string
… and it reads number, I have to comment out slice method line of code
… original code to see that error message says TypeError: cardNumber.slice is not a function
…e quotes around the numbers and printing last4Digits
…$ so the the first varible was name was updated to start with doller sign
…er name for the variable
…nsole for Object.md file
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
|
|
||
| let initials = ``; | ||
| let initials = `"${firstName[0]}${middleName[0]}${lastName[0]}"`; |
There was a problem hiding this comment.
Note: Usually the double quotes surrounding a string are not part of the sting value; they are only used to indicate the boundary of the string.
No change needed.
| @@ -1,9 +1,17 @@ | |||
| const cardNumber = 4533787178994213; | |||
| const cardNumber = "4533787178994213"; | |||
There was a problem hiding this comment.
Suppose you were not allowed to modify the statement const cardNumber = 4533787178994213;
(that is, keep the variable's value unchanged).
How would you modify the code (through type conversion) to still being able to use .slice(-4) to extract the last 4 digits from the given number.
| const $12HourClockTime = "8:53pm"; | ||
| const _hourClockTime = "20:53"; No newline at end of file |
There was a problem hiding this comment.
Identifiers that begin with _ or $ are valid variable names. However, they are usually used by convention to signal special meaning.
Could you explore names that start with alphabets instead? Feel free to ask AI for suggestion.
| // 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? | ||
|
|
||
| // 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? | ||
| // The error is occurring on line 5., and it's a SyntaxError: missing , The error is due to a missing comma in the replaceAll() method. The correct syntax should be replaceAll(",", ""). To fix this problem, we need to add the missing comma in the replaceAll() method on line 5 |
There was a problem hiding this comment.
We could more precisely describe "A comma is missing between "," and "" in the function call" as:
A comma is missing between the ___________s.
Could you look up the programming term that belongs in the blank?
Learners, PR Template
Self checklist
Changelist
This is PR for coursework Solutions for Sprin-1 of the "Module-Structuring- and Testing-Data Module, it covers key exercises on JavaScript fundamentals (variable assignments, string manipulations , String methods ,random numbers , and mandatory error fixing activities along with interpretation exercises that test understanding of code behaviour and syntax .
1-key-exercises/ — 4 files with solutions for count, initials, paths, and random number generation
2-mandatory-errors/ — 5 files fixing syntax/logic errors (comments, variable scope, type issues, naming)
3-mandatory-interpret/ — 3 files with detailed explanations of code behavior
4-stretch-explore/ — 2 files exploring browser APIs and object concepts