Repository navigation
London | 26-ITP-Sep| Mandip Sanger | Sprint 2 | Coursework #1469
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 17 commits
0015f48
8b470cc
2135afb
e331dbb
74a3d77
97aaeda
ffe85e6
cf901b6
3585299
60a9900
729eef2
7c00cb0
e5c1675
98ceee2
0be3a97
c17f6b2
2db087e
b002fba
ec2d5c8
6c105ea
570b271
d911165
0605160
aa6ee27
fc6cdad
cbe3cb0
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,10 +1,12 @@ | ||
| const firstName = "Creola"; | ||
| const middleName = "Katherine"; | ||
| const lastName = "Johnson"; | ||
| let firstName = "Creola"; | ||
| let middleName = "Katherine"; | ||
| let lastName = "Johnson"; | ||
|
|
||
| // Declare a variable called initials that stores the first character of each string. | ||
| // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
|
|
||
| const initials = ``; | ||
| let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; | ||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
| console.log(initials); | ||
| //remove const | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| // const age = 33; | ||
| // age = age + 1; | ||
|
|
||
| let age = 33; | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| // 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"; | ||
|
|
||
| // return has not been defined before it is used in the console.log statement. | ||
| // To fix this, you should declare and assign a value to the variable cityOfBirth before using it in the console.log statement. | ||
| // To do this, you can move the line const cityOfBirth = "Bolton"; above the console.log statement. | ||
| // This way, the variable will be defined before it is used, and the code will work as expected. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| 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 | ||
| // returns an error because the slice method is not available for numbers. The slice method is a string method, and cardNumber is a number. | ||
| // To fix this, we need to convert cardNumber to a string before using the slice method. We can do this by using the toString() method or by using template literals. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const twelveHourClockTime = "8:53pm"; | ||
| const twentyFourHourClockTime = "20:53"; | ||
|
|
||
| // 12 Hour clock time is a string that represents the time in 12-hour format, while 24hourClockTime is a string that represents the time in 24-hour format. | ||
|
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. Line 10 answers the question. Lines 4 to 9 answer a different question: how to convert 12 hour time. Delete lines 4 to 9.
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 can't see the original file which question was asked so trying to download the original file.
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 have deleted lines 4 to 9 please see if it shows.
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. Sorry I didnt see this comment. There were so many feedback.
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. That's the one. |
||
| // To convert 12HourClockTime to 24-hour format, we can use the following steps: | ||
| // 1. Split the string into hours and minutes using the split() method. | ||
| // 2. Check if the time is in the "pm" period. If it is, add 12 to the hours (unless it's 12pm). | ||
| // 3. If the time is in the "am" period and the hour is 12, set the hour to 0. | ||
| // 4. Format the hours and minutes into a string in 24-hour format. | ||
Uh oh!
There was an error while loading. Please reload this page.