-
-
Notifications
You must be signed in to change notification settings - Fork 337
Sheffield | 26-Jan-ITP | Karim Mhamdi | Sprint 1 | Coursework/sprint-1 #1092
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 2 commits
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,4 @@ | ||
| /* | ||
| 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? | ||
| */ |
| 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) |
| 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 ? | ||
| // what's the error ? The error was cannot acess 'cityofBirth' before initialization. | ||
| // This happpend becouse CityofBirth was declared with a const but was used before its decleration. | ||
|
cjyuan marked this conversation as resolved.
Outdated
|
||
|
|
||
| const cityofBirth = "Bolton"; | ||
| console.log(`I was born in ${cityofBirth}`); | ||
|
|
||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const last4Digits = cardNumber.toString().slice(-4); | ||
| 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 | ||
|
|
||
| /* | ||
| Prediction: It wont work because cardNumber is a number and slice() only works on strings. | ||
| Error: TypeError - cardnumber.slice is not a function. | ||
| Explanation: Numbers dont have the slice method. | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const hour12HourClockTime = "20:53"; | ||
| const hour24HourClockTime = "08:53"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,13 @@ 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 | ||
| // 1. Stores "399p" as a string | ||
| // 2. removes the "p" at the end | ||
| // 3. adds zeros at the start if needed to make it 3 digits. | ||
| // 4. Takes everything except the last 2 digits as pounds. | ||
| // 5. Prints the result in this format: £3.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. (4) and (5) does not quite describe the code on lines 14-16. Also, could we expect this program to work as intended for any valid
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. #1092 (comment) |
||
|
|
||
| // To begin, we can start with | ||
| // I also tested it by changing 399p to 50p and the result was £0.50 thats shows diffrent numbers well have diffrent outputs | ||
|
|
||
| // To begin, we can start wit | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
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.
Code is correct.
On line 21, there are some trailing space characters.
Trailing spaces do not affect program execution, but they can influence how Git detects changes in a file.
If you enabled "Format on save" in VSCode, and you have installed "prettier" extension, VSCode can automatically indent the code and remove all trailing space characters.
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.
You didn't remove the extra trailing space.
Have you follow the recommended setup described in https://github.com/KKtech06/Module-Structuring-and-Testing-Data/blob/main/readme.md?