generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 336
London | 26-ITP-Jan | Alex Okorefe | Sprint 1 | Coursework #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Alex-Os-Dev-Lab
wants to merge
15
commits into
CodeYourFuture:main
Choose a base branch
from
Alex-Os-Dev-Lab:coursework/sprint-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+236
−17
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9db28b2
Added notes to described what the code on line 3 is doing
Alex-Os-Dev-Lab 683ae71
Declared variable initials to store 1st chars of strings
Alex-Os-Dev-Lab fca74e9
assigned values to variables dir and ext (3-paths.js)
Alex-Os-Dev-Lab 906ab34
included notes to work out what num represents; by breaking down the …
Alex-Os-Dev-Lab a273daa
converted instruction lines into comments
Alex-Os-Dev-Lab c0c20fc
changed const to let to allow age variable to be reassigned
Alex-Os-Dev-Lab 934aeec
place cityOfBirth variable and assigned value ahead of console log st…
Alex-Os-Dev-Lab 2cd98a1
converted cardNumber to string to achieve desired output and included…
Alex-Os-Dev-Lab 846928b
updated variable names to start with letters to fix syntax error
Alex-Os-Dev-Lab 0fad45e
answered Qs with updates notes fixed syntax error to ensure code runs…
Alex-Os-Dev-Lab 976fb67
updated notes to answer question
Alex-Os-Dev-Lab af47636
updated penceString file and expanded comments to include breakdown a…
Alex-Os-Dev-Lab 1fca7d0
Improve comments for random number generation logic
Alex-Os-Dev-Lab 461e977
Fix method to get last 4 digits of card number
Alex-Os-Dev-Lab 078e937
Fix comment on function call count in 1-percentage-change.js
Alex-Os-Dev-Lab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| console.log(count); | ||
|
|
||
| // 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 | ||
|
|
||
| // Line 3 is reassigning the value of the count variable to the result of the expression count + 1. | ||
| // The = operator is the assignment operator, which assigns the value on the right-hand side | ||
| // (the result of count + 1) to the variable on the left-hand side (count). | ||
| // This increments the value of count by 1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| 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? | ||
| //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? | ||
|
|
||
| //We solve the problem by commenting out the lines - | ||
| // this means that the computer will ignore them when it runs the program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; | ||
|
|
||
| console.log(age); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); | ||
|
|
||
| //ReferenceError: Cannot access 'cityOfBirth' before initialization | ||
|
|
||
| // This is happening because we are trying to use the variable cityOfBirth | ||
| // before it has been declared and assigned a value. | ||
|
|
||
| // Variables declared with let and const can't be accessed before they are initialized. | ||
|
|
||
| // To fix this error, we need to declare and assign a value to cityOfBirth before we try to log it to the console. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.tostring().slice(-4); | ||
|
|
||
| console.log(last4Digits); | ||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
| // Before running the code, make and explain a prediction about why the code won't work | ||
| // Then run the code and see what error it gives. | ||
| // 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 | ||
|
|
||
| // initial prediction: | ||
| // I don't think the code will work because cardNumber is a number, and the slice method is a string method. | ||
|
|
||
| // The error I get is: TypeError: cardNumber.slice is not a function | ||
|
|
||
| // This error is happening because the slice method is being called on a number, | ||
| // which does not have the slice method. The slice method is only available for strings and arrays. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; | ||
|
|
||
| console.log(twelveHourClockTime, twentyFourHourClockTime); | ||
|
|
||
| //SyntaxError: Invalid or unexpected token | ||
|
|
||
| // This error is happening because variable names cannot start with a number. | ||
| // To fix this error, we can change the variable names to start with a letter instead of a numbers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very thorough analysis.
Could we expect this program to work as intended for any valid
penceStringif we deleted.padEnd(2, "0")from the code? In other words, do we really need.padEnd(2, "0")in this script?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey CJ I see where you're coming from. Since paddedPenceNumberString is guaranteed to be at least 3 characters long due to the padStart(3, "0") call in step 3, the substring(length - 2) will always return exactly two characters. Therefore, .padEnd(2, "0") is redundant I will remove it and make the code more efficient.