-
-
Notifications
You must be signed in to change notification settings - Fork 240
Glasgow | 25-ITP-SEP | Alaa Tagi | Sprint 2 | coursework/sprint-2 #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Alaa-Tagi! You did a great job working on the exercises but there are several things you need to revisit.
Sprint-2/1-key-errors/0.js
Outdated
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
| function capitalise(str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function has another syntax error after you made some changes. Could you please fix it?
Sprint-2/1-key-errors/0.js
Outdated
| // =============> write your new code here : | ||
| /* | ||
| function capitalise(str) { | ||
| let cap = `${str[0].toUpperCase()}${str.slice(1)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well but something to consider for future is that variable names should be more descriptive, so it's easier for readers of your code to understand what this variable holds.
| //The correct code : | ||
| const decimalNumber = 0.5; | ||
|
|
||
| function convertToPercentage(decimalNumber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works nicely but as an optional exercise, could you think of a way to simplify the code within this function?
Sprint-2/2-mandatory-debug/0.js
Outdated
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| // =============> write your prediction here : There is no return statement for the parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain your prediction better? What does the no return statement for the parameters mean and how do you think it affects the function behaviour?
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your explanation here : /* The function multiply does not return any value, it only logs the result to the console. It returns undefined. To fix this, we need to add a return statement in the multiply function. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent explanation!
| // return the BMI of someone based off their weight and height | ||
| } | ||
| const bmi = weight / (height * height); | ||
| return bmi.toFixed(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine but something to keep in mind is that .toFixed() would return a string. It can be okay in this case as we don't have a strict requirement for the return type but something to be careful about while using this method.
| const upperCase = name.toUpperCase(); // Convert the string to uppercase | ||
| return upperCase.replaceAll(" ", "_"); // Replace all spaces with underscores | ||
| } | ||
| console.log(snakeItUp("alaa tagi is my name")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you calling the right function here?
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
|
|
||
| function toPounds(penceToPound) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cleanly written code with super descriptive variable names. Great job!
|
|
||
| // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // =============> write your answer here : "00", because num is converted to string and padded to 2 characters with "0". That's mean "1" becomes "01". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a typo in this answer, could you please double check if it's correct?
| ); // It's output is correct | ||
|
|
||
| //Fixing the function: | ||
| function formatAs12HourClockFixed(time) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test cases you added are good but some edge cases to consider:
- Passing invalid time such as
"25:30"or"15:78"
2 Passing an empty string""as parameter
Edit: I edited my comment to make it simpler for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @jennethydyrova i have corrected all the things that you have mentioned earlier and push it to git .
would you please see if it correct?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Alaa-Tagi, could you please double check if all tests are passing this file? It looks like tests are correct but they would fail.
|
hi @Alaa-Tagi! I think you are almost there with this PR but your
Can you add assertions for these inputs and see what's missing in your function? |
|
Great job @Alaa-Tagi! |
Learners, PR Template
Self checklist
Changelist
I have created a PR after making all the tasks required.
Questions
No questions.