generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 315
London | 26-ITP-January | Eugenie Ahangama | Sprint 1 | coursework/sprint-1 #927
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
Eugenie-A
wants to merge
21
commits into
CodeYourFuture:main
Choose a base branch
from
Eugenie-A: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
21 commits
Select commit
Hold shift + click to select a range
b72e206
Added comments explaining assignment operator on line 3
Eugenie-A 3044863
Added comments explaining how + joins strings and how [0] gets the fi…
Eugenie-A 025f800
Added console.log to display the initials result
Eugenie-A 16fe3c5
Added logic to extract the directory part of the file path
Eugenie-A a014507
Added logic to extract the extension part of the file path
Eugenie-A c4aa0c2
Added step by step breakdown of random number generation
Eugenie-A 4e3483f
Added console logs and comments to show each step of the random numbe…
Eugenie-A 59c9c2e
Added comments to prevent instructions lines from running
Eugenie-A 20bd1ee
Fixed spelling error in comment line
Eugenie-A 658e7a7
Changed the reassignment from const to let to print the result
Eugenie-A bad8580
Explained initialisation error and corrected variable order in 2.js
Eugenie-A 8f50754
Explained why slice() failed on a number and updated last4Digits to c…
Eugenie-A 1631f4e
Fixed invalid variable names in 4.js and replaced smart quotes with v…
Eugenie-A d29e07d
Completed A-E: Error analysis, function calls, variable declarations,…
Eugenie-A 376454f
Completed tasks a-f with explanations and test analysis
Eugenie-A a8ef7ce
Added pence-to-pounds solution with line by line breakdown and test c…
Eugenie-A c35d043
Completed exercise 4: console methods and dot syntax explanation
Eugenie-A 8aeec63
Completed prompt/alert tasks: explained return values, assignment beh…
Eugenie-A f711afc
fix: improved 1-count.js comments with 'increment' term + MDN links
Eugenie-A ed68c8b
fix: used precise interval notation [0, 1) in Math.random comment
Eugenie-A 40015f6
fix: corrected console object description in objects.md per feedback
Eugenie-A 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,7 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| count = count + 1; // increment: adds 1 and assigns the new value back | ||
|
|
||
| // 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 | ||
| // MDN Increment operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment | ||
| // MDN Assignment operators: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators#Assignment_operators | ||
| // Alternatives: count += 1 or count++ |
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,28 @@ | ||
| const minimum = 1; | ||
| const maximum = 100; | ||
|
|
||
| const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
| const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Generates a random whole number between minimum and maximum | ||
|
|
||
| // In this exercise, you will need to work out what num represents? | ||
| // Try breaking down the expression and using documentation to explain what it means | ||
| // It will help to think about the order in which expressions are evaluated | ||
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| // Generates a random decimal number in the interval [0, 1) | ||
| // (includes 0, excludes 1) | ||
| // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random | ||
| const decimal = Math.random(); | ||
| // Calculates the range size | ||
| const range = maximum - minimum + 1; | ||
| // Scales the decimal to the range | ||
| const scaled = decimal * range; | ||
| // Rounds down to get a whole number | ||
| const floored = Math.floor(scaled); | ||
| // Shifts the number up to start at the minimum | ||
| const result = floored + minimum; | ||
| // Logs each part to understand the process | ||
| console.log("decimal:", decimal); | ||
| console.log("range:", range); | ||
| console.log("scaled:", scaled); | ||
| console.log("floored:", floored); | ||
| console.log("result:", result); |
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,2 @@ | ||
| 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? |
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 allows reassignment whereas const does not | ||
| 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
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,8 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| // Prediction: The code will fail because variable names cannot start with a number. | ||
| // JavaScript identifiers must begin with a letter, $, or _. Starting with a 12 or 24 is invalid. | ||
| // The quotes used are also smart quotes which will cause a syntax error. | ||
|
|
||
| // Corrected code: | ||
|
|
||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "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
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.
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.
After testing: removing
.padEnd(2, "0")doesn't change the output for valid inputs (e.g. "399p" → "£3.99") because.padStart(3, "0")already gurantees the last two characters are correctly padded.So no, you don't really need
.padEnd(2, "0")in this code, the output remains correct without it.