Repository navigation
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.
1 similar comment
This comment has been minimized.
This comment has been minimized.
iscmiguelsamaniego
left a comment
There was a problem hiding this comment.
Fantastic work! Your technical grasp, attention to edge cases (like octal numbers), and step-by-step code breakdowns are spot-on.
Keep up this meticulous approach—you are making brilliant progress!
There was a problem hiding this comment.
Great job! You correctly identified how the variable is initialized and reassigned.
Quick question: How would you specifically describe the role of the = sign in that second line?
There was a problem hiding this comment.
//Line two we see the variable count using the = sign to assign a new value whcih is count previous value + 1
//the equal sign in line two is assigned operator that stores the new value to the variable
There was a problem hiding this comment.
Great job! This is a very clean and clever solution using template literals and bracket notation.
Quick question: Is there another built-in string method besides bracket notation you could use to get the first character?
There was a problem hiding this comment.
Spot-on implementation for extracting dir and ext! To polish your code, you can make the comments a bit more direct and concise.
Quick question: When using filePath.slice(0, lastSlashIndex) for dir, why do we include 0 as the starting index, and what happens if you omit it?
There was a problem hiding this comment.
If we omit the first index, the string won't break but will go to the wrong location; in the case of omitting the 0 index, it will delete anything before the last index ''/'
There was a problem hiding this comment.
Clear breakdown of the math logic!
Just remember the order: Math.random() runs first to generate a decimal, then the math scales it, and finally Math.floor() rounds it down.
Quick question: What purpose does the + 1 serve inside (maximum - minimum + 1)?
There was a problem hiding this comment.
I had to search for this one to understand it. Math.random() generates a decimal that ranges between the values 0 and 0.99999, so when we try to scale it up Math.random() will generate values between 0 and 8.9999, so it doesn't include 9. This becomes an issue when we use Math.floor as it will round it to the nearest whole number, and because it doesn't include the number 9, it will round down from 0 to 8.
There was a problem hiding this comment.
Spot-on distinction between const and let for handling variable updates.
Quick question: Is there a shorthand assignment operator you could use instead of writing age = age + 1?
There was a problem hiding this comment.
Not quite a ReferenceError here—cardNumber is actually declared, but because it's a number rather than a string, JavaScript throws a TypeError because .slice() isn't a valid method for numbers.
Quick question: What method can you call on cardNumber to convert it into a string first so .slice(-4) will work?
There was a problem hiding this comment.
Spot-on explanation! Variable names cannot start with numbers.
Quick question: While starting with a capital letter works syntactically, what is the standard JavaScript naming convention (case style) usually used for variables made of multiple words like this?
There was a problem hiding this comment.
Spot-on answers! Your breakdown of line 5's syntax error, reassignments, and the purpose of replaceAll() is completely accurate.
Quick question: Why is replaceAll() a better choice here than a standard replace() method?
There was a problem hiding this comment.
replaceAll includes all the specified characters and changes them, unlike replace(), which searches for the character but stops once it is found.
There was a problem hiding this comment.
Spot-on analysis! Your observation about leading zeros triggering an octal syntax error is a brilliant and advanced catch.
Quick question: If remainingSeconds is 5, the output currently shows ...:5 instead of ...:05. How might you ensure single-digit numbers always display with two digits?
There was a problem hiding this comment.
Since the digit zero is before the 5. We create a numerical string, then convert the string to a numerical value or add the zero digit as a string before the number or we modify the function to include strings so we can manipulate the numbers.
There was a problem hiding this comment.
Great step-by-step breakdown! You clearly traced how substring, padStart, and padEnd work together to parse and format the price string correctly.
Quick question: Why is padStart(3, "0") particularly important if someone inputs a smaller value like "9p" instead of "399p"?
There was a problem hiding this comment.
It specify the starting values so we don't have random numbers that could cause a bug in the program. We restrict it.
This comment has been minimized.
This comment has been minimized.
5 similar comments
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.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thank you so much for this wonderful feedback. I certainly will check each one and submit my work for each one. It was really good to hear that I did a good job; I was really worried I might have made some mistakes. |
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.
1 similar comment
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.
Rawan, you've answered every question, and some of the hardest parts are right: dir and ext in 3-paths.js work for any file name, and your fixes in 1.js and 4.js run. I ran each file with node, and a few answers need another go before this can be marked Complete. I've left a step-by-step hint on each one.
How to run a file: in VS Code, right-click the folder (for example 2-mandatory-errors), choose Open in Integrated Terminal, then type node 3.js and press Enter. Run each file after you change it.
What to do:
3-to-pounds.js: delete the copied code on lines 48 to 53 so the file runs again, then add the value to each step (hints on lines 44 and 49).2.js: change the order of the code so it printsI was born in Bolton(line 4).3.js: fix line 2 and change ReferenceError to TypeError (line 10).1.js,2.js,3.js,4.js: copy the error message node prints into each file (line 6 of 1.js shows how).4-random.js: fix "nearest" on line 22 and say whatnumis.2-time-format.js: redo c), d) and f) (lines 22 and 26).1-percentage-change.jse): say whatNumber(...)does (line 24).- Delete lines that start with
//and contain old code: 3-paths.js lines 12-15, 21-22, 35, 37, 39, plus your notes on lines 29 and 60; 2-initials.js line 8; 4.js lines 5-6 (after you've copied its error message). - Format each file: right-click inside the file, choose Format Document, then save. Do this for all 12 files.
Once these are pushed, I expect to mark this Complete. Add the Needs Review label again when you have pushed.
| //paddedPenceNumberString.substring value is found by starting from the first index WITH LENGTH 3 and ending with paddedPenceNumberString.length subtracted by the operator 2 | ||
|
|
||
| // IN THIS LINE const pence = paddedPenceNumberString | ||
| const pence = paddedPenceNumberString |
There was a problem hiding this comment.
Lines 49 to 53 are copies of the program's own code (lines 14 to 18), so const pence is now created twice. Node refuses to run the file: SyntaxError: Identifier 'pence' has already been declared.
Delete lines 48 to 53, then run node 3-to-pounds.js. You should see £3.99 printed once. Your explanation should only be // comments; the program itself stays exactly as it was given.
| // 0, | ||
| //paddedPenceNumberString.length - 2 | ||
| //); | ||
| // we assign the value to be starting with MINUMUM LENGTH IS 3 CHARACTERS than if not ADD THE VALUE 0 TO THE BEGINNING |
There was a problem hiding this comment.
Your steps say which method is used, but not what it gives. Write the value each line produces for "399p". Here is step 2 as an example:
// 2. penceString.length is 4, so penceString.length - 1 is 3.
// substring(0, 3) keeps characters 0, 1 and 2, giving "399" (the p is removed).
Now do the same for the rest, filling in the ...:
// 3. padStart(3, "0") gives "..."
// 4. pounds is "..."
// 5. pence is "..."
// 6. the console.log prints ...
Then change line 1 to "9p", run it, and write down what it prints. What did padStart do to "9"? Change line 1 back to "399p" afterwards.
| @@ -3,3 +3,5 @@ | |||
|
|
|||
| console.log(`I was born in ${cityOfBirth}`); | |||
There was a problem hiding this comment.
Your explanation on line 7 is right. JavaScript runs the file from top to bottom, and line 4 uses cityOfBirth before line 5 has created it.
So what order should these two lines be in? Change it, run node 2.js, and you should see I was born in Bolton.
| // 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 | ||
| // in this case its a reference error the program is trying to access a value that wasn't declared. In this case a variable. No newline at end of file |
There was a problem hiding this comment.
This one isn't a ReferenceError. Run the file and look at the last line of the error: node says TypeError: cardNumber.slice is not a function. cardNumber is there (line 1), but it holds a number, and .slice() only works on strings.
- In your thread reply you found
toString(). Put it betweencardNumberand.slice(-4)on line 2. Addconsole.log(last4Digits);underneath and run it: you should see4213. - Replace line 10 with three comments in your own words:
// Prediction: ...
// Error: TypeError: cardNumber.slice is not a function
// Why: ...
| let age = 33; | ||
| age = age + 1; | ||
|
|
||
| //we change the variable declaration and reassign its value |
There was a problem hiding this comment.
Your fix is right. This section also wants the error message node gives for the original code. To see it:
- Change
letback toconston line 3 and runnode 1.js. - Copy the line that starts with
TypeErrorinto a comment here. - Change
constback tolet.
Do the same in 4.js (remove the // from line 5 for a moment), and in 2.js and 3.js before you fix them. Each file should end up with the error message and your explanation.
| // * is a multiplication operator | ||
| // to understand what is going on we need to understand what the floor and random methods do | ||
| //Math.floor (rounds down to the nearest whole number) and than pass it to Math.floor | ||
| // we are asking the program to round whatever result we have to the nearest whole number No newline at end of file |
There was a problem hiding this comment.
Two things here.
Math.flooralways rounds down, as you said on line 21.Math.floor(4.9)is 4, not 5. Change "nearest" on line 22.- The question asks what
numrepresents. Addconsole.log(num);after line 4 and run the file ten times. Then finish with one line:
// So num is a random whole number from ... to ...
Your thread reply already explains why the + 1 is there, so you can copy that in too.
| // "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? | ||
|
|
||
| // it means the number of minutes in a film is calculated by calculating the number of seconds in the film |
There was a problem hiding this comment.
c) and d) need the numbers from this program. Add these two lines after line 4 and run the file:
console.log(remainingSeconds);
console.log(totalMinutes);
Then fill in:
// c) movieLength % 60 is ..., which is the seconds left over after ...
// d) totalMinutes is ..., the number of whole minutes. Line 4 takes away remainingSeconds first so that ...
Delete the two console.log lines afterwards.
|
|
||
| //the variable result represesnt the length of the film in hours,minutes,and seconds. A better name would be movie time. | ||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // However, it doesn't work when the leading number of a decimal is zero like this 08784 because it interpreted as octal literal and 8 can't work in octal numeration |
There was a problem hiding this comment.
const movieLength = 08784; actually runs and prints 2:26:24, because 8 isn't an octal digit, so JavaScript reads it as a normal number. So this answer needs changing.
Change line 1 to each of these, run the file, and write down what it prints: 59, 3605, -100, 90.5. Would you show 0:0:59 to someone as a time? What would you expect it to look like instead? Write one sentence for each value that doesn't look right. Put line 1 back to 8784 afterwards.
|
|
||
| //four lines 1,2,7,8 | ||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
| //The replace.all method is used to include the car price and the price after one year of depreciation. |
There was a problem hiding this comment.
You've explained replaceAll. Now Number(...). Add these two lines and run the file:
console.log(typeof carPrice); // put this before line 4
console.log(typeof carPrice); // put this after line 4
What changes? Write one sentence about what Number(...) did, and why line 7 needs it before subtracting. Then delete the two lines.

Self checklist
Task code
CYF-1039
Changelist
Sprint 2 work
Questions
No questions