London | 26-ITP | Mars Adesina | Sprint 2 | Javascript Fundamentals - #1559
marscancode wants to merge 43 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
❌ Deploy Preview for cyf-onboarding-module failed. Why did it fail? →
|
✅ 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.
Good work on this sprint. Your prediction in 2-mandatory-errors/3.js is honest and clear. You say what you expected and what was different.
Four things to fix before I can mark it Complete:
1-key-exercises/4-random.jsline 5: this line stops the file with an error. Remove it.1-key-exercises/4-random.jsline 14: the answer needs to say whatnumis. See my comment on that line.2-mandatory-errors/1.js: the fix works, but the error and the reason are not written down.1-key-exercises/3-paths.jsline 18:extonly works for this one file name.
Also, "My code is consistently formatted" is on the checklist. The tool that does this is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer only sees the changes you meant to make. At the moment 2-mandatory-errors/0.js fails that check.
Prettier comes with the CYF extension pack from onboarding. If you are not sure you have it, open VS Code, go to Extensions, and search for CodeYourFuture Extension Pack: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack
Open 0.js, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save and commit. To format every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
Add the Needs Review label again once you have pushed.
| const maximum = 100; | ||
|
|
||
| const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
| num = Math.floor(Math.random(0.9) * (100 - 1 + 1)) + 1; |
There was a problem hiding this comment.
Run node 4-random.js inside the Sprint-2/1-key-exercises folder. What is the first line of the error?
num is declared with const on line 4. A const cannot get a new value. Please delete line 5.
| //console.log(num) | ||
| //output: random whole number | ||
|
|
||
| // So num is storing the value of a random number generated by the method Math.random this will be a number between zero and one that is then multiplied by 100 (100(maximum) -1(minimum) +1) and then whatever this number is, one is added on to that number and then finally the Math.floor method will round that number down to the nearest whole number add one and this final number is what is stored in the variable num. |
There was a problem hiding this comment.
Two things in this answer.
First, you say one is added before Math.floor, and again after it. The + minimum happens once. Look at the brackets on line 4. Which happens first, Math.floor or + minimum?
Second, finish with what num is. What is the smallest value it can be? What is the largest?
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; |
There was a problem hiding this comment.
The fix is right. The exercise also asks for the error and the reason.
The starter had const age = 33; on this line. Add a comment with the first line of the error node printed. Then say in your own words why it happened.
Tip: the error in 1-key-exercises/4-random.js right now is the same one.
|
|
||
| // https://www.google.com/search?q=slice+mdn No newline at end of file | ||
| const dir = filePath.slice(0, lastSlashIndex); | ||
| const ext = base.slice(4); |
There was a problem hiding this comment.
This gives .txt for file.txt. What does it give if base is photo.jpeg?
The number 4 only fits a name with four letters. How can you find where the . is, like you found the last / on line 13?
There was a problem hiding this comment.
slice(-4) still counts four characters from the end. What does it give for photo.jpeg?
The . is not always four characters from the end. On line 13 you used lastIndexOf to find the last /. Can you do the same for the .?
There was a problem hiding this comment.
I have made the changes and pushed it now. I didn't think about the slice method not working for every extension type because they differ in length but after reviewing my code on line 13, I understand now why using the lastindex of method for the ext variable is correct here! Thanks so much Abdi!
There was a problem hiding this comment.
That's the one. Your comment on line 19 explains it well.
|
Thankyou for reviewing my work Abdi! I have fixed my code to be in line with the things you pointed out and i've pushed the changes so hopefully all should be correct now. |
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Thank you for the quick fixes. Your answer in 4-random.js is now clear. It gives the order and the range 1 to 100.
One thing left: ext in 1-key-exercises/3-paths.js. See my reply on line 18.
Add the Needs Review label again once you have pushed.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
ext is fixed. It gives .txt for file.txt and .jpeg for photo.jpeg.
One small note, no need to change it now. Line 12 has an extra photo/ in the path. So the //44 comment on line 13 is out of date.
Marking this Complete. Well done.

Learners, PR Template
Self checklist
Task code
CYF-1039
Changelist
Completed all 4 sections of the sprint-2 coursework.