-
-
Notifications
You must be signed in to change notification settings - Fork 337
Birmingham | 26-ITP-JAN | Merve Reis | Sprint 1 | Module Structuring and Testing Data #1091
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
base: main
Are you sure you want to change the base?
Changes from all commits
9c6bef1
10e3a62
faf70eb
d031689
0197521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| 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? | ||
| 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? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,6 @@ | |
|
|
||
| const age = 33; | ||
| age = age + 1; | ||
|
|
||
| let age = 33; | ||
| age = age + 1; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const 24hourClockTime = "08:53"; | ||
|
|
||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,9 @@ const pounds = paddedPenceNumberString.substring( | |
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| const pence = paddedPenceNumberString.substring( | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| console.log(`£${pounds}.${pence}`); | ||
|
|
||
|
|
@@ -23,5 +23,24 @@ console.log(`£${pounds}.${pence}`); | |
| // You need to do a step-by-step breakdown of each line in this program | ||
| // Try and describe the purpose / rationale behind each step | ||
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| //1. const penceString = "399p": initializes a string variable with the value "399p" | ||
|
|
||
| // 2 to 6.const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); | ||
| // removes the (p) at the end determined by removing the sudstring at the total length of the string -1 | ||
|
|
||
| // 8.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| // makes sure the string is at least 3 characters long and if it is not it padds it with "0" | ||
|
|
||
| // 9.const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2); | ||
| // gets the ammout of pounds by making a sub string that starts at the firts character (0) to the paddedPenceNumberString length -2 to exclued the last 2 characters (the p) | ||
|
|
||
| // 10.const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2); | ||
| // Gets the amount of pence by making a substring that starts at the paddedPenceNumberString length -2 to get the last 2 characters | ||
|
Comment on lines
+37
to
+38
Contributor
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. Optional challenge:
Author
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. I'll test it in this way, thanks for this challenge. @cjyuan |
||
|
|
||
| // 18.console.log(`£${pounds}.${pence}`); | ||
| // gives the console the result using a string literal | ||
| //console.log(`£${pounds}.${pence}`); : | ||
|
|
||
| // Combines the pounds and pence into a standard currency format and prints it to the console, "£3.99" | ||
| // The program takes a string representing a price in pence (e.g., "399p") | ||
| // and converts it to a string representing the price in pounds (e.g., "£3.99"). | ||
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.
Should be
[0, 1).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.
Sorry, I missed that, I fixed it. @cjyuan