generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 333
Cape Town | 2026-ITP-Jan | Pretty Taruvinga | Sprint 1 | Structuring and Testing Data #985
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
Pretty548
wants to merge
15
commits into
CodeYourFuture:main
Choose a base branch
from
Pretty548: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
8fc0686
answered a question
373185a
answered questions 2 and 3
7ba1aab
added the forward slashes to solve the problem
37a866a
used let instead of const because i am changing the value
894dc7a
added backticks and moved the variable above the console.log
e8ea254
i added .tostring()
9600e13
renamed the variable
8b28453
. fixed a syntax error
484f884
added answers to exercise 1
03e8867
Merge remote-tracking branch 'origin/sprint1/key-exercises' into cour…
7a87c6c
Merge remote-tracking branch 'origin/sprint1/mandatory-errors' into c…
4060f63
Update BMI calculation to round using toFixed
a983056
fix syntax error explanation
fb86516
Fix truncated explanation in to-pounds step-by-step breakdown
2884e82
Restore BMI file to state before Sprint-2 changes
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,4 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| // 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
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 = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,72 @@ | ||
| const penceString = "399p"; | ||
| // This line declares a constant variable named `penceString` and assigns it the value "399p". | ||
| // This string represents a price in pence. | ||
|
|
||
| const penceStringWithoutTrailingP = penceString.substring( | ||
| 0, | ||
| penceString.length - 1 | ||
| ); | ||
| // This removes the trailing "p" from the string, leaving only the numeric value. | ||
|
|
||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| // Ensures the number has at least 3 digits by adding leading zeros if necessary. | ||
|
|
||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
| // Extracts the pounds part of the value. | ||
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| // Extracts the last two digits to represent the pence value. | ||
|
|
||
| console.log(`£${pounds}.${pence}`); | ||
| // This line constructs a string in the format "£X.XX" where X represents the pounds and pence values, and then prints it to the console. | ||
| // Prints the formatted price such as "£3.99". | ||
|
|
||
| // This program takes a string representing a price in pence | ||
| // It then removes the trailing "p" character, pads the number with leading | ||
| // zeros to ensure it has at least 3 digits, and then separates the pounds and pence parts of the number. | ||
|
|
||
| // The program then builds up a string representing the price in pounds | ||
| // and pence format (e.g., "£3.99") by concatenating the pounds and pence parts together with a "£" symbol and a decimal point. The final output is printed to the console. | ||
|
|
||
| // This program takes a string representing a price in pence (e.g., "399p") and converts it into a formatted string representing the price in pounds and pence (e.g., "£3.99"). | ||
| // by concatenating the pounds and pence parts together with a "£" symbol and a decimal point. The final output is printed to the console. | ||
|
|
||
| // You need to do a step-by-step breakdown of each line in this program | ||
| // a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
| // 1. penceString.substring(0, penceString.length - 1) - line 3 | ||
| // 2. penceStringWithoutTrailingP.padStart(3, "0") - line 5 | ||
| // 3. paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2) - line 6 | ||
| // 4. paddedPenceNumberString.substring(paddedPenceNumberString.length - 2) - line 9 | ||
| // 5. padEnd(2, "0") - line 9 | ||
| // 6. console.log(`£${pounds}.${pence}`) - line 11 | ||
|
|
||
| // Try and describe the purpose / rationale behind each step | ||
| // 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? | ||
| // c) Identify all the lines that are variable reassignment statements | ||
| // d) Identify all the lines that are variable declarations | ||
| // e) Describe what the expression penceString.substring(0, penceString.length - 1) is doing - what is the purpose of this expression? | ||
|
|
||
| // a) How many function calls are there in this file? | ||
|
|
||
| // 1. penceString.substring(0, penceString.length - 1) | ||
| // Removes the trailing "p" from `penceString` by taking a substring that excludes the last character. | ||
|
|
||
| // 2. penceStringWithoutTrailingP.padStart(3, "0") | ||
| // Ensures the string has at least 3 digits by adding leading zeros if needed. | ||
|
|
||
| // 3. paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2) | ||
| // Extracts the pounds part by taking all digits except the last two. | ||
|
|
||
| // 4. paddedPenceNumberString.substring(paddedPenceNumberString.length - 2) | ||
| // Extracts the last two digits to represent the pence value. | ||
|
|
||
| // 5. padEnd(2, "0") | ||
| // Ensures the pence value always has two digits by adding trailing zeros if necessary. | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| // 6. console.log(`£${pounds}.${pence}`) | ||
| // Prints the final formatted price in pounds and pence to the console. | ||
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.