generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 275
West Midlands | 25 Sep ITP | Iswat Bello | Sprint 1 | Module Structuring and Testing Data #744
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
Iswanna
wants to merge
16
commits into
CodeYourFuture:main
Choose a base branch
from
Iswanna: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.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
beda3cd
Add comment to explain what the assignment operator does on line 3
Iswanna cdfcef0
Write code to extract the first letter of each string
Iswanna d845bba
Create variables to store the dir and ext parts of the filepath variable
Iswanna 2c9afad
Explain the expression assigned to const num
Iswanna bbcddb9
Interpret the error message
Iswanna 5b0c0bc
Interpret error message when a const variable is reassigned
Iswanna 0835346
Interpret error message for when a variable is used before declaration
Iswanna 2deec27
Compare prediction with actual error message and fix the code
Iswanna 2f25058
Interpret the error message that occurs when a number starts a variab…
Iswanna 4aaf415
Comment out the code with the error
Iswanna b9f2f51
Identify function calls, errors, variable declarations/reassignments,…
Iswanna 3090d19
Comment out the console.log function
Iswanna 03cb451
Explain variables, function calls, expressions, and result interpreta…
Iswanna 095a3ea
Give a step-by-step breakdown of each line in this program
Iswanna 1030764
Fix code to correctly extract the .txt file extension
Iswanna 11a2c20
Rename variables to indicate 12-hour and 24-hour formats
Iswanna 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,11 @@ | ||
| 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 | ||
|
|
||
| //Answer | ||
| // The third line is a statement that reassigns the value of count to count + 1. | ||
| // The assignment operator (=) updates the variable count with a new value. |
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,11 @@ | ||
| 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? | ||
|
|
||
| // Interpretation: | ||
| // The error "SyntaxError: Unexpected identifier 'is'" means that JavaScript found the word "is", but it didn’t make sense in that position. | ||
| // It wasn’t valid code that JavaScript could understand. | ||
|
|
||
| // Why the error occurred: | ||
| // The error occurred because the sentence was written as plain text instead of a comment. | ||
| // To fix it, the sentence should be written as a comment (by adding // at the beginning) so that JavaScript ignores it. | ||
|
|
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,9 +1,22 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| // const cardNumber = 4533787178994213; | ||
| // const last4Digits = cardNumber.slice(-4); | ||
|
|
||
|
|
||
| // 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 | ||
|
|
||
|
|
||
| // Answer | ||
| // The code will not work because the slice method in javascript only works on a string or an array. | ||
| // The data type of the value stored in the variable cardNumber is a number and for this reason, the code will return an error. | ||
| // After running the code, it gave an error " TypeError: cardNumber.slice is not a function" | ||
| // My prediction and the error align. | ||
| // To update the code, I will convert the variable cardNumber to a string first then use slice() method after | ||
|
|
||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.toString().slice(-4); | ||
| console.log(last4Digits); |
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,12 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| // const 12HourClockTime = "20:53"; | ||
| // const 24hourClockTime = "08:53"; | ||
|
|
||
| // console.log(12HourClockTime , 24hourClockTime); | ||
|
|
||
| // Answer | ||
| // After running the code, it gave an error message "SyntaxError: Invalid or unexpected token". | ||
| // This error means that Javascript was unable to read the code because a variable name cannot start with a number | ||
| // I can fix this code by removing the numbers from the start of the variable name | ||
|
|
||
| const time24HourFormat = "20:53"; | ||
| const time12HourFormat = "08:53"; |
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.
Why do you think the variable minimum is added to the expression?
Uh oh!
There was an error while loading. Please reload this page.
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.
Hi @tenzyns.
I added the variable
minimumto the expression inorder to shift the range so the random number starts from the minimum value instead of 0. Without it, the result would be between 0 and (maximum - minimum), but adding minimum ensures it’s between minimum and maximum (inclusive).