Birmingham | 26-ITP-May | Toluwalase Tiamiyu | Sprint 1 | Coursework#1380
Birmingham | 26-ITP-May | Toluwalase Tiamiyu | Sprint 1 | Coursework#1380TTiamiyu wants to merge 21 commits into
Conversation
…g out the initials
… values in a loop
…or identification in percentage change calculation
…, and calculations in time formatting
…e pence to pounds conversion process
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing | ||
|
|
||
| The = served as the executer of the assignment operation. No newline at end of file |
There was a problem hiding this comment.
Suggestion: In JavaScript a single-line comment starts with // and is ignored by the JavaScript engine. Can you look where all can you use it.
There was a problem hiding this comment.
Thank you for your suggestion, i have effected the comment tag to my response.
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing | ||
|
|
||
| The = served as the executer of the assignment operation. No newline at end of file |
There was a problem hiding this comment.
What will be the new value of count after statement at line 3 is executed ?
There was a problem hiding this comment.
The new count value would would be '0 + 1' = 1.
|
|
||
| // Export the initials for testing instead of returning at top-level | ||
| module.exports = getInitials; | ||
|
|
There was a problem hiding this comment.
You have properly use function and the output is the expected string "CKJ", but instead of using a function, can you try to get the same result by Declare a variable called initials
There was a problem hiding this comment.
There are a couple of ways to declare initials using the 'let' statement, i have used one of them in my recent commit.
| const dir = ; | ||
| const ext = ; | ||
| const dir = ; /Users/mitch/cyf/Module-JS1/week-1/interpret/ | ||
| const ext = ; file.txt; |
There was a problem hiding this comment.
Is the semicolon position correct while declaring variable dir and ext ?
There was a problem hiding this comment.
I have taking the semicolon out as its not required when '=' is in use.
| // Create a variable to store the ext part of the variable | ||
|
|
||
| const dir = ; | ||
| const ext = ; |
There was a problem hiding this comment.
Think of ways to use slice method extract and store directory part and extension part in the variable dir and ext respectively.
There was a problem hiding this comment.
Thank you for your review, i have infused the .slice method and i have used the console.log to recall the answer to 'dir' and 'ext', rather than manually inputting it.
| //This is just an instruction for the first activity - but it is just for human consumption | ||
| //We don't want the computer to run these 2 lines - how can we solve this problem? | ||
|
|
||
| To prevent the computer from executing these lines of code, you can comment them out, |
There was a problem hiding this comment.
How will you use multi-line comment for line 4 and 5 ?
There was a problem hiding this comment.
i made use of the " /* " to comment out line 4 and 5.
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
|
||
| PREDICTION: | ||
| //the code wont work because the card number isnt in ("") and the computer wont be able to apply the .slice due to this. |
There was a problem hiding this comment.
It is good practice to use single line comment or multiline comment whenever required.
try looking for lines which needs to be ignored by computer in the code.
There was a problem hiding this comment.
I see what you mean and i have commented out the headings i created earlier.
| FIX: | ||
| const cardnumber = "4533787178994213"; | ||
| const last4Digits = cardnumber.slice(-4); | ||
| console.log(last4Digits); |
There was a problem hiding this comment.
Is there any function that you can use to convert number to string in JS ?
There was a problem hiding this comment.
I can use String(num) or num.toString() after i have used a "let" declare statement preceding the use of the stated function.
|
|
||
| // 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 in line 5, the error is occurring because there was a comma missing here; ("," ""). | ||
|
|
There was a problem hiding this comment.
Instead of writing comma is missing here, we can put it like "Comma is missing "," and "" for priceAfterOneYear.replaceAll("," "") function call.
There was a problem hiding this comment.
Your suggestion is better and i have incorporated it, thank you.
| //It will do the math perfectly for most normal positive numbers, but there are a few situations where the code will act wierdly. | ||
| //1. Visual problems | ||
| //2. Negative numbers | ||
| //3.Decimal numbers |
There was a problem hiding this comment.
I am not sure about Visual Problems, can you describe what you mean by it.
We can also consider any Non-Integer numbers .
There was a problem hiding this comment.
What i mean with this is The "Single Digit" Visual Bug where the output would not look like a normal digital clock.
I was hoping the non integer numbers would be captured under the decimal numbers response i provided
…eAfterOneYear.replaceAll function call
Learners, PR Template
Self checklist
Changelist
In this PR the coursework to test the basics of structuring and testing data was done and committed regularly