London | 26-ITP-Sep | Chandaramani Gaire | Sprint 2 | Sprint 2 Coursework - #1575
gaireprakash20-ops wants to merge 18 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Your 1-percentage-change.js answers a) to e) are all right, and you fixed the missing comma on line 5 too. 3-paths.js also works well, because you used lastIndexOf for ext.
I have left a hint on each line. These are the things to fix before I can mark this Complete:
-
Six files stop with a SyntaxError, so none of their code runs:
0.js,1.js,2.js,4.js,1-percentage-change.jsand2-time-format.js. Each one has a comment that starts with/*but never ends. Add*/at the end of each/*comment. Then run each file with node to check. -
2-mandatory-errors: your explanations are good, but the code in1.js,2.js,3.jsand4.jsstill fails. Fix each one so it runs with no error. -
2-initials.jslines 4 and 8. -
4-random.jsline 13: finish the breakdown. -
2-time-format.js: answers c), d) and f). -
"My changes follow the style guide" is on your checklist, and consistent formatting is part of it. The tool that does it is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer only sees the changes you meant to make. Right now most of your files fail 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
Then open each file you changed, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save, commit and push. 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
Fix point 1 first. Prettier cannot format a file that has a SyntaxError.
Add the Needs Review label again once you have pushed.
| We don't want the computer to run these 2 lines - how can we solve this problem? No newline at end of file | ||
| /*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? | ||
| for single line we used // and for multiple line use /* No newline at end of file |
There was a problem hiding this comment.
Your idea is right. /* starts a comment over many lines. But a /* comment must also end, with */. Add */ at the end of line 3.
Then run node 0.js. It should print nothing and show no error. Five more files have the same problem.
There was a problem hiding this comment.
i did as per the instruction
There was a problem hiding this comment.
Fixed. It runs now.
| const middleName = "Katherine"; | ||
| const lastName = "Johnson"; | ||
|
|
||
| const CKJ = "something" |
There was a problem hiding this comment.
The task says you must not write C, K or J in your code. Line 4 has all three. Line 4 is not used anywhere, so you can delete it.
There was a problem hiding this comment.
i deleted the line 4
| const initials = ``; | ||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn | ||
| const initials = `"${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}"`; |
There was a problem hiding this comment.
Run the file. It prints "CKJ", with quote marks. The task wants CKJ. The quote marks come from the two " inside your backticks. What happens if you delete them?
There was a problem hiding this comment.
when i delete i saw CKJ only
There was a problem hiding this comment.
Fixed. It prints CKJ now.
|
|
||
| // In this exercise, num represent the value integer number between 1 to 100. | ||
| //Math.random generates a random decimal number from 0 up to 1, but not including, 1. | ||
| // down to the nearest whole number (integer). |
There was a problem hiding this comment.
Line 13 starts in the middle of a sentence. I think it is about Math.floor. Please finish it.
Two steps are also missing. Math.random() * (maximum - minimum + 1) is Math.random() * 100. That gives a decimal from 0 up to 100. Math.floor then makes it a whole number from 0 to 99. So what does + minimum do at the end?
There was a problem hiding this comment.
Lines 14 and 15 are right. Line 13 still starts with "down to". Which function rounds down? Add its name at the start of line 13.
| age = age + 1; | ||
|
|
||
| /* In this case age is not const means variable is not reassigned so that, | ||
| we throws a TypeError: Assignment to constant variable.2 |
There was a problem hiding this comment.
You found the right message: TypeError: Assignment to constant variable. But the file still stops with that error. Which keyword lets you give a variable a new value later? Use it on line 3.
There was a problem hiding this comment.
i delete const and put let than i type console.log(age) terminal shows the 34
There was a problem hiding this comment.
Fixed. It prints 34 now.
| @@ -1,9 +1,12 @@ | |||
| const cardNumber = 4533787178994213; | |||
| const last4Digits = cardNumber.slice(-4); | |||
| const last4Digits = string(cardNumber).slice(-4); | |||
There was a problem hiding this comment.
Your prediction on line 11 is right. Now run node 3.js. It stops with a new error: ReferenceError: string is not defined. In JavaScript, capital letters matter in names. Is string the same as String?
There was a problem hiding this comment.
String is a javascript function and string is just a letters. I change the String but i cant not fixed the ReferenceError in this section
There was a problem hiding this comment.
It works now. Run node 3.js. It prints 4213, so there is no ReferenceError any more. Fixed.
| @@ -1,2 +1,3 @@ | |||
| const 12HourClockTime = "8:53pm"; | |||
| const 24hourClockTime = "20:53"; | |||
| /*variable is not start with number show syntaxerror. | |||
There was a problem hiding this comment.
Your reason is right. A variable name cannot start with a number. Now rename the two variables on lines 1 and 2, so the file runs. For example, you can move the number to the end of the name, or write it as a word.
There was a problem hiding this comment.
I just move the number at the end rather than make long words.
There was a problem hiding this comment.
Fixed. It runs now.
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| /*The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend. |
There was a problem hiding this comment.
This is what % does in general. In this program, movieLength % 60 gives 24. Are those 24 seconds, minutes or hours? Write what the 24 means in this program.
There was a problem hiding this comment.
24 is the second i did "Percent (%) is a way to describe the full amount of anything by imagining it split into 100 equal sections."
There was a problem hiding this comment.
Yes, 24 seconds. Please write that in the file, under c). Your answer must be in the file, not only here.
Also delete line 35. It is about percent. But here % is the remainder operator. It is not percent.
| /*The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend. | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| /* This expression convert movies time second into minutes dividend by 60 second. |
There was a problem hiding this comment.
Dividing by 60 is the second step. First, (movieLength - remainingSeconds) takes the 24 leftover seconds away. Why do that before dividing by 60? Try 8784 / 60 in node and look at the result.
There was a problem hiding this comment.
Line 36 is right. The seconds come out first, so dividing by 60 gives a whole number. Please move it under d).
| We can change this name as movieTime. | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| /* In this section we can only use the positive natural numbers but if we put numbers that divide by 60 without a remainder get the exact time like 10, 20 50. |
There was a problem hiding this comment.
You are right that positive whole numbers work. Now try -90 and 90.5 as movieLength. What does the program print each time? Would you show a time like that? Write what you see.
Also, 10, 20 and 50 cannot be divided by 60 with no remainder. Which numbers can?
There was a problem hiding this comment.
i did not shows the error
There was a problem hiding this comment.
Right, there is no error. But look at the time it prints. Set movieLength to -90 and run the file. What does it print? Would a clock show that time? Do the same with 90.5. Write what you see in f).
Also line 34: 10, 20 and 50 are smaller than 60, so they leave a remainder. Which numbers divide by 60 with no remainder?
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
i changed as per your instruction
abdishakoor-dev
left a comment
There was a problem hiding this comment.
You fixed a lot. 0.js, 1.js, 3.js, 4.js and 2-initials.js all run with the right result now. Your step for + minimum in 4-random.js is right.
Still to do before I can mark this Complete:
-
2.jsand1-percentage-change.jsstill stop with a SyntaxError. Each/*comment needs*/at its end.2.jsalso still needs lines 4 and 5 swapped, and the error name. -
4-random.jsline 13: it still starts in the middle of a sentence. -
2-time-format.js: write c) in the file, delete line 35, and answer f). See my replies. -
Prettier. Most of your files are not formatted yet. Do this after point 1, because Prettier cannot format a file with a SyntaxError. For each file you changed:
- Open the file in VS Code.
- Right click anywhere in the code.
- Choose Format Document. If VS Code asks which formatter to use, choose Prettier.
- Save the file with
Ctrl + S.
Then commit and push.
Add the Needs Review label again once you have pushed.
| // d) Identify all the lines that are variable declarations | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| /* there has five function in line 4 and and console . log also has one |
There was a problem hiding this comment.
Your answers here are right. But this /* never ends. So node reads everything after it as one comment, and stops with a SyntaxError. Add */ at the end of each answer. Then run node 1-percentage-change.js. It should print the percentage change.
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
i did many mistake in git hub what should i do
|
ssss |

Self checklist
Task code
CYF-1039
Changelist
Answer the question and make changes per the question's requirements.