-
-
Notifications
You must be signed in to change notification settings - Fork 389
London | 26-ITP-May | Martin Mwaka | Sprint 1 | Coursework Exercises #1333
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
Temceo
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
Temceo: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
18 commits
Select commit
Hold shift + click to select a range
8970f33
add comment to 1-key-exercises/1-count.js
Temceo 1d21cfd
complete initials exercise in 1-key-exercises/2-initials.js
Temceo ffb5c73
create required variables in 1-key-exercises/3-paths.js
Temceo 87c2ec7
add my answer to 1-key-exercises/4-random.js
Temceo ee07d17
convert written text to comments in 2-mandatory-errors/0.js
Temceo 72167f9
update 2-mandatory-errors/1.js
Temceo 477607c
fix error in 2-mandatory-errors/2.js
Temceo 995e53b
fix error and add comments to 2-mandatory-errors/3.js
Temceo 805a500
fix error and add comment in 2-mandatory-errors/4.js
Temceo dad5f5b
fix error and add comments to 3-mandatory-interpret/1-percentage-chan…
Temceo 64eba1c
add my answers to 3-mandatory-interpret/2-time-format.js
Temceo d9a30d6
add my answers to 3-mandatory-interpret/3-to-pounds.js
Temceo b1459e5
Update my answer to 1-key-exercises/1-count.js
Temceo c5cb33e
Update my answer to 1-key-exercises/2-initials.js
Temceo 5670537
Update my answer to 1-key-exercises/4-random.js
Temceo 0ff83ab
Update my answer to 1-key-exercises/4-random.js
Temceo 34421f1
Update my answer to 2-mandatory-errors/3.js
Temceo 9e484d4
Update my answer to 3-mandatory-interpret/1-percentage-change.js
Temceo 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
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,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 age = 33; | ||
| age = age + 1; | ||
|
|
||
| // Martin comment - const cannot be reassigned. I have changed the declaration to let which allows the value of age to be reassigned |
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,7 @@ | ||
| // 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}`); | ||
| // Martin response - cityOfBirth was being logged before it was declared. I have moved the variable initialisation above the console.log line and this now works as expected. | ||
|
|
||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); |
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,14 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const last4Digits = (cardNumber % 10000).toString().padStart(4, "0"); | ||
| 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 | ||
|
|
||
| // Martin comment before running the code - Slice is a string method. In this case it fails because it is being used against a number | ||
|
|
||
| // Martin comment after running the code - when I run the code it gives the error - 'number.slice is not a function'. When I research online I discover this error occurs when the slice method is applied to a value that is not a string or an array. I have resolved this by doing research on line and discovering that modulo can be used to extract digits from a long number. By converting it to a string and adding a padStart of 4 characters, I ensure that 4 string characters are returned even in the event of a number such as 12340000 |
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,6 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const _12HourClockTime = "8:53pm"; | ||
| console.log(_12HourClockTime); | ||
| const _24hourClockTime = "20:53"; | ||
| console.log(_24hourClockTime); | ||
|
|
||
| // Martin comment - a variable cannot begin with a number. I have converted both to start with an underscore |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.