-
-
Notifications
You must be signed in to change notification settings - Fork 337
London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 1 | Coursework #1090
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 30 commits
d20c0a3
3428f41
38427c2
2f3f08d
44271ba
e0b3256
21914bb
17d93a6
af48176
4ba270e
67c8968
b72751f
35fdc82
4fdfb07
d100737
3bcd5ba
5809aee
eee4034
db44748
429f649
92bd8ef
56b74d5
5196c63
122c731
7d09f40
7b87fbc
652dbc1
bbdcc95
177c368
3bb9ddf
fcb6413
2292f32
f92ac80
10386dd
b3b93d6
3438d6e
e8a1bf4
3f4904a
39274a2
8b934c0
c4c751f
2c58925
e1ef649
6f289e8
0dfa642
7a2b695
9d78d99
60af85c
8ce4854
314fa85
0d3adae
99f2a39
ce5e2ad
dd973e6
a7d7dfd
0714db2
895a3ad
41d60eb
64c8174
a0791ac
40804b4
c301336
dc13db4
784fb4b
987f735
8eed65b
ad6a628
a68f546
9256617
0391e7d
eac0a04
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? | ||
| // to make the computer not running these two line we use inline comments by adding two slashes at the beginning of each line |
| 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; // we should use the keyword 'let' to declare the variable 'age' to allow reassignment later | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| // 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}`); | ||
|
|
||
| // the error is that the variable 'cityOfBirth' is declared after the statement it is used in |
| 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); | ||
|
cjyuan marked this conversation as resolved.
Outdated
|
||
|
|
||
| // 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 | ||
|
|
||
| /* my prediction about why the code isn't working is because either the new variable is declared with const keyword | ||
| or the value of the variable cardNumber is a number not a string whereas the method .slice works only with strings */ | ||
| // the error it gives 'cardNumber.slice is not a function' | ||
| // It gives this error because the computer assumes the coder is trying to invoke a function | ||
| // yes it is my second prediction | ||
| // updating the expression last4Digits is assigned to, in order to get the correct value is as follows | ||
| // method one: puting the value of the variable cardNumber into quotes | ||
| // method two: invoking the method .toString() to convert the type of the variable from number to string | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const _12HourClockTime = "20:53"; // identifier can not begin with a number | ||
| // or | ||
| const $12HourClockTime = "20:53"; // or any change that makes the identifier not stating with digit | ||
| const _24hourClockTime = "08:53"; // identifier can not begin with a number | ||
| // or | ||
| const $24hourClockTime = "08:53"; // or any change that makes the identifier not stating with digit | ||
|
cjyuan marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,8 @@ console.log(`£${pounds}.${pence}`); | |
|
|
||
| // To begin, we can start with | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| // line 3: calling substring method to remove the 'p' letter and keep only digits in the string | ||
| // line 8: using padstart method to make the minimum length of the string to 3 characters by adding one zero or two to the left. | ||
| // line 9: using substring method to take only the integer part | ||
| // line 14: using substring method to take only the decimal part and padend method to make the minimum length of pence to 2 characters by adding zero to the right | ||
|
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: |
||
| // line 18: calling console function to print the integer part that represents the pound and the decimal part that represents the pence seprated by point | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,5 +16,3 @@ function square(3) { | |
| // Finally, correct the code to fix the problem | ||
|
|
||
| // =============> write your new code here | ||
|
|
||
|
|
||
|
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. There should not be modified files in the Sprint-2 folder in a PR created for Sprint-1 exercise. Can you revert (undo) the changes made in the Sprint-2 folder? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,26 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| // =============> the function when called will throw an error | ||
|
|
||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> the function multiply has no return statement | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| // =============> | ||
| function multiply(a, b) { | ||
| return (a * b); // we change the console.log statement with the return statement | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // an extra notice: the purpose of creating a function is to reuse it when needed | ||
| // I've noticed that the parameters are already assigned to values 10 and 32, so I changed the code to the following: | ||
| function multiply(a, b) { | ||
| return console.log(`The result of multiplying ` + a +` and ` + b +` is ` + (a * b)); | ||
| } | ||
| multiply(10, 32); |
Uh oh!
There was an error while loading. Please reload this page.