-
-
Notifications
You must be signed in to change notification settings - Fork 389
Manchester | May-2026-ITP | Monsur Abdulrahman | Sprint 1 | Coursework Exercises #1334
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
Monsur0001
wants to merge
15
commits into
CodeYourFuture:main
Choose a base branch
from
Monsur0001: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
15 commits
Select commit
Hold shift + click to select a range
8095f51
Refactor initials variable assignment to directly concatenate first c…
Monsur0001 3fd21e6
Implement dir and ext variable assignments in file path extraction
Monsur0001 688f25b
Breaking the expression and explaining what they mean
Monsur0001 63c562a
Improve documentation clarity by adding inline comments to expression…
Monsur0001 cab937e
Add comments to prevent execution of instructional lines in 0.js
Monsur0001 7186dfa
Change age variable declaration from const to let for reassignment
Monsur0001 27bff53
Fix console log placement to correctly print city of birth
Monsur0001 2f2a720
Fix last4Digits assignment to correctly use slice on string represent…
Monsur0001 1cc8d56
Fix variable naming to follow camelCase convention for clock time con…
Monsur0001 89ca1ed
Add detailed comments to explain function calls, error identification…
Monsur0001 f402c6f
Enhance comments for clarity on variable declarations, function calls…
Monsur0001 ed8a5e7
Add detailed comments to explain each step of the pence to pounds con…
Monsur0001 9d06c8b
Refactor comments for clarity and consistency in 3-to-pounds.js
Monsur0001 d3193ff
Add explanations for prompt function effects in chrome.md
Monsur0001 d60c972
Enhance explanations in objects.md for console output and syntax usage
Monsur0001 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,5 @@ | ||
| // 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,8 @@ | ||
| // 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}`); | ||
|
|
||
|
|
||
|
|
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,21 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const last4Digits = cardNumber.toString().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 | ||
|
|
||
| The code didnt work because the slice method was called on an integer (cardNumber), | ||
| but slice is a method that is only available for strings and arrays. | ||
| Since cardNumber is an integer, it does not have the slice method, | ||
| which will result in an error when the code is run. | ||
|
|
||
| // Then run the code and see what error it gives. | ||
| The error was: TypeError: cardNumber.slice is not a function | ||
|
|
||
| // Consider: Why does it give this error? Is this what I predicted? If not, what's different? | ||
| It gives this error because the slice method is not meant for numbers. This is what I predicted, as I expected that calling slice on an integer would result in a TypeError. | ||
|
|
||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
|
||
| const last4Digits = cardNumber.toString().slice(-4); |
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 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const twelveHourClockTime = "8:53pm"; | ||
| const twentyFourHourClockTime = "20: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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,35 @@ console.log(`The percentage change is ${percentageChange}`); | |
| // Read the code and then answer the questions below | ||
|
|
||
| // a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
| there are 4 function calls in this file. | ||
| The lines where a function call is made are: | ||
|
|
||
| 1. carPrice.replaceAll(",", "") | ||
| 2. Number(carPrice.replaceAll(",", "")) | ||
| 3. priceAfterOneYear.replaceAll("," "") | ||
| 4. Number(priceAfterOneYear.replaceAll("," "")) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good work finding these, I think there is one more function call to find |
||
| // 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 coming from the line: | ||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
|
|
||
| The error is occurring because there is a missing comma in the replaceAll method. The correct syntax should be: | ||
|
|
||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); | ||
|
|
||
| // c) Identify all the lines that are variable reassignment statements | ||
| The lines that are variable reassignment statements are: | ||
| 1. carPrice = Number(carPrice.replaceAll(",", "")); | ||
| 2. priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); | ||
|
|
||
| // d) Identify all the lines that are variable declarations | ||
| The lines that are variable declarations are: | ||
| 1. let carPrice = "10,000"; | ||
| 2. let priceAfterOneYear = "8,543"; | ||
| 3. const priceDifference = carPrice - priceAfterOneYear; | ||
| 4. const percentageChange = (priceDifference / carPrice) * 100; | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| The expression Number(carPrice.replaceAll(",", "")) is performing two operations: | ||
| 1. It is using the replaceAll method to remove all commas from the string value of carPrice, resulting in a string that represents a number without any formatting (e.g., "10000"). | ||
| 2. It is then converting that string into a number using the Number() function, so that it can be used in mathematical calculations. | ||
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
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.
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.
Good break down of the individual steps. Can you give a short explanation of what the script does overall?