London | 26-ITP-May | Bisrat Tesfay | Sprint 2 | Coursework/sprint 2#1455
London | 26-ITP-May | Bisrat Tesfay | Sprint 2 | Coursework/sprint 2#1455B3-Bisrat wants to merge 7 commits into
Conversation
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| //The function multiply(a, b) logs the result but does not return anything. |
There was a problem hiding this comment.
This is true, but I'm looking for a little more specifics. When the line
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);is run, what do you see and why? Your comment should provide a thorough explanation of this.
There was a problem hiding this comment.
The function multiply(a, b) prints the result using console.log(a * b), but it does not return a value. When multiply(10, 32) is called inside the template literal, it first prints 320 to the console. Then, because the function has no return statement, it returns undefined. As a result, the second console.log prints:
The result of multiplying 10 and 32 is undefined
This happens because console.log() only displays a value on the screen, while return sends a value back to where the function was called.
There was a problem hiding this comment.
Yep, spot on - could you please update your answer in the file to use this level of detail? Then I'm happy to mark as complete 🙂
| console.log(formatAs12HourClock("00:00")); | ||
| console.log(formatAs12HourClock("12:00")); | ||
|
|
||
| //The function did not handle the edge cases 00:00 and 12:00. |
There was a problem hiding this comment.
You are absolutely correct that it didn't handle those two edge cases! Please update the function accordingly to ensure it does handle them (and also handles slightly different inputs as well, please refer to the prep steps for a reminder of the kinds of inputs you need to handle).
There was a problem hiding this comment.
Thanks for the feedback! I've updated the function
Learners, PR Template
Self checklist
Changelist
All the sprint 2 coursework are done.
Questions