London | 26-ITP-May | Ebrahim Moqbel | Sprint 2 | course work - #1582
London | 26-ITP-May | Ebrahim Moqbel | Sprint 2 | course work #1582Ebrahim-Moqbel wants to merge 16 commits into
Conversation
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
| } | ||
| capitalise("ebrahim"); |
There was a problem hiding this comment.
You call the function but never print it, so the file outputs nothing
| // =============> write your new code here | ||
| } | ||
| capitalise("ebrahim"); | ||
| capitalise('salomi'); |
There was a problem hiding this comment.
You call the function but never print it, so the file outputs nothing
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
| return str[0].toUpperCase()+str.slice(1); |
There was a problem hiding this comment.
It is correct, but the code itself needs formatting. Missing indent inside the function
There was a problem hiding this comment.
Still outstanding. Run npx prettier --write Sprint-2 from the repo root and it'll fix the formatting across all the files. Turning on format on save in VS Code will keep it that way.
| // =============> write your prediction here | ||
| /* | ||
| I predict the function will throw a SyntaxError as the variable str has already been declared in the function parameter | ||
| function capitalize will capitalise the first letter with index 0 |
There was a problem hiding this comment.
a typo in capitalize, since the function has different name.
| /* the reason why getLastDigit isn't working properly is that it doesn't accept any arrguments where there isn't any perameters in its difination. | ||
| where it uses the golabal varaible 'num' decalred outside the funtion and already set to 103 | ||
|
|
||
| The correct code includes a parameter 'number' in the difination this allows the function to accept the number passed to it when called*/ No newline at end of file |
| // return the BMI of someone based off their weight and height | ||
| } No newline at end of file | ||
| let result = Number(weight/(height*height)); | ||
| return result.toFixed(1); |
There was a problem hiding this comment.
I would drop the Number on the devision and than return Number(..)
| // You will need to come up with an appropriate name for the function | ||
| // Use the MDN string documentation to help you find a solution | ||
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
| function toUpperSnakeFormat(string){ |
There was a problem hiding this comment.
rename to match the vocabulary brief in the link, i.e toUpperSnakeCase
There was a problem hiding this comment.
Coming back to this one. The function is still called toUpperSnakeFormat. Rename it to toUpperSnakeCase to match the wording in the exercise, or tell me why you prefer the current name.
|
I have committed the suggested changes and answered the questions if there is any further requirements please do let me know @selyafi Thank you |
|
|
||
| // =============> write your explanation here | ||
| /* The variable decimal Number has already been declared in the parameter | ||
| and already is a local variable which can't be declared again causing a ReferenceError |
There was a problem hiding this comment.
Try running the original code. That's a SyntaxError, not a ReferenceError, and it stops the file before anything runs, so the console.log problem you predicted never happens. Update your explanation to match.
|
|
||
| // =============> explain this error message here | ||
| /* The function was givin a number as its perameter where in JS only allows varaible names and usnig a number causes a SyntaxError | ||
| Also, the function was returning num*num where num is undefined causing a ReferenceError |
There was a problem hiding this comment.
Same thing here. function square(3) is a SyntaxError, so the file never runs and num * num never executes. Delete the last sentence about the ReferenceError.
|
|
||
| // b) What is the value assigned to num when pad is called for the first time? | ||
| // =============> write your answer here | ||
| // =============> the first time pad was called with the totalHours |
There was a problem hiding this comment.
Answer with the value, not the variable name. Run formatTimeDisplay(61) and check what totalHours is at that point.
|
|
||
| // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // =============> "1" |
There was a problem hiding this comment.
Check where remainingSeconds comes from and fix the answer. pad is what turns it into a string, on its first line.
Learners, PR Template
Self checklist
Changelist
reviewed the completed mandatory exercises and the key errors file further explaining and running the codes for revision purposes and submitting a new PR for the sprint
Questions
N/A