-
-
Notifications
You must be signed in to change notification settings - Fork 302
London|May-2025|Alexandru Pocovnicu|Coursework|sprint 1 #494
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
Changes from all commits
330e776
4766394
a9835a2
0589f1b
f0ca65e
a035308
2b670cf
1d67096
8cd337f
cf91d1e
ef6d8f0
145c8fd
60f84be
5b4927e
918e2ec
247e919
5b765e6
71eb97d
f34420b
cb3fd97
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,3 @@ | ||
| 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?*/ | ||
| // we turn it in to a comment |
| 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; |
| 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 ? | ||
| const cityOfBirth = "Bolton"; | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const _12HourClockTime = "20:53"; | ||
| const _24hourClockTime = "08:53"; | ||
| console.log(_12HourClockTime,_24hourClockTime) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,20 @@ const penceStringWithoutTrailingP = penceString.substring( | |
| 0, | ||
| penceString.length - 1 | ||
| ); | ||
| console.log(penceStringWithoutTrailingP) | ||
|
|
||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| console.log(paddedPenceNumberString) | ||
|
|
||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| console.log(pounds) | ||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
|
|
||
| console.log(pence) | ||
| console.log(`£${pounds}.${pence}`); | ||
|
|
||
| // This program takes a string representing a price in pence | ||
|
|
@@ -25,3 +28,16 @@ console.log(`£${pounds}.${pence}`); | |
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| /* 3-6. const penceStringWithoutTrailingP = penceString.substring( | ||
| 0, | ||
| penceString.length - 1 | ||
| );: creates a string variable called penceStringWithoutTrailingP with the value "399" | ||
| 9. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");:it creates a string variable has at least three characters | ||
| if it doesn't it will add one or more '0' | ||
| 12-15. const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| );:it creates a string variable with the value of '3' | ||
| 17-19. it creates a string variable that has the value of the last 2 characters from '399' which is '99' | ||
|
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. Could we expect this program to work as intended for any valid
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. in this script we don't need it , padStart(3,0) takes care of that |
||
| 21.it logs the values of £ with pounds ,. , and pence combined resulting in £3.99 | ||
| */ | ||
Uh oh!
There was an error while loading. Please reload this page.