-
-
Notifications
You must be signed in to change notification settings - Fork 382
Birmingham | 26-ITP-Jan | Arunkumar Akilan | Sprint 1 | Structuring-and-Testing-Data Coursework/Sprint1 #1017
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 17 commits
5f999c7
90f27bb
a5c9ea0
3de2b1d
88670e7
240da0e
1413d04
ad59545
2589dc7
14c0fe3
4982dbf
0dc471c
a9067eb
0daa315
3af2171
0d90b74
73c30ee
21eed1b
51cc2d8
d89e043
4602c77
77f51a4
e6d8b17
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,6 +1,12 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| // count = count + 1; | ||
|
|
||
| // count += 1; | ||
|
|
||
| count++; | ||
|
|
||
| console.log(count); | ||
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing | ||
| // In line 3 they are reassign the value for count by adding count+1 and = here called assigning operator | ||
| 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,5 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
| // what's the error ? Ans:They i try to prin the cityOfBirth before it was defined | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.slice(-4); | ||
|
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. Suppose you were not allowed to modify the statement
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. .slice() only works on strings. Initially I didn’t know about type conversion, so I changed the number into a string and then used .slice(-4) to extract the last four digits.
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. .slice() only works on strings, so we first convert the number to a string. Number(String(cardNumber).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 | ||
|
|
||
| // Slice() works on String(characters) not number | ||
| //Numbers Don't have Indexes and strings do | ||
| // So converting to String allowed me to cut the last 4 Digit of the card number. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const $24HourClockTime = "20:53"; | ||
| const $12hourClockTime = "08:53"; | ||
|
cjyuan marked this conversation as resolved.
Outdated
|
||
| console.log($24HourClockTime) | ||
| console.log($12hourClockTime) | ||
| // | ||
Uh oh!
There was an error while loading. Please reload this page.