London | 26-ITP-SEP | Bartosz Kawiak | Sprint 2 | Course-work-2 - #1542
bartoszkawiak wants to merge 9 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Thanks for redoing the branch. It is clean now.
There are some issues to fix here:
-
2-mandatory-errors/: run0.js,1.js,2.jsand4.jswith node. Each one stops with an error. Only3.jsgets to the end. See my comment on each file. -
1-key-exercises/2-initials.jsprintsC, notCKJ. -
1-key-exercises/3-paths.jsline 21, see my comment. -
3-mandatory-interpret/2-time-format.jsline 1 has been changed from the original, see my comment.
Add the Needs Review label again when you have pushed.
| // 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 = ``; | ||
| const initials = firstName.charAt(0); |
There was a problem hiding this comment.
Run this file. It prints C. Lines 9 and 10 work out the other two characters, but nothing keeps the result, so initials only holds the first one. How can you join all three into one string?
| const dir = ; | ||
| const ext = ; | ||
| const dir = filePath.slice(0, lastSlashIndex); | ||
| const ext = filePath.slice(-4); |
There was a problem hiding this comment.
dir on line 20 is right. For ext, change the file name in filePath to photo.jpeg and run it again. What do you get? Line 13 finds the last / in the path. Could you use the same idea to find the .?
| @@ -1,2 +1,5 @@ | |||
| This is just an instruction for the first activity - but it is just for human consumption | |||
There was a problem hiding this comment.
Your answer on line 4 is right. Have you run the file since you wrote it? Lines 1 and 2 are still read as JavaScript, so node stops here. This exercise wants you to change these two lines, not only describe how it would be done.
| @@ -2,3 +2,5 @@ | |||
|
|
|||
| const age = 33; | |||
| age = age + 1; | |||
There was a problem hiding this comment.
You have written that let is needed, and that is correct. But line 3 still says const, so the file still stops with an error when you run it. Make the change so the file runs.
| @@ -3,3 +3,8 @@ | |||
|
|
|||
| console.log(`I was born in ${cityOfBirth}`); | |||
| const cityOfBirth = "Bolton"; | |||
There was a problem hiding this comment.
Good explanation, and the right error. The file still stops when you run it though. What would you move, so that line 4 prints "I was born in Bolton"?
| @@ -1,2 +1,4 @@ | |||
| const 12HourClockTime = "8:53pm"; | |||
There was a problem hiding this comment.
You are right about why this happens. Both names are still here though, so node cannot read the file at all. What would you rename them to?
| @@ -1,4 +1,4 @@ | |||
| const movieLength = 8784; // length of movie in seconds | |||
| const movieLength = -8784.08; // length of movie in seconds | |||
There was a problem hiding this comment.
This was 8784 in the original. It looks like you changed it to try a negative decimal, which is the right thing to try. Put the original value back though, because your answers to c and d describe the original numbers. Then write down in answer f what you saw when you tried the negative value.
|
Ignore point 4 on my review, about putting |

Learners, PR Template
Self checklist
Task code
CYF-1039
Changelist
Corrected version of : #1532
Completed the Sprint 2 JavaScript exercises, including working with variables, strings, methods, operators, function calls, and basic objects. Added answers and explanations to the exercise questions.