-
-
Notifications
You must be signed in to change notification settings - Fork 244
Manchester | 25-ITP-Sep | Mahtem T. Mengstu | Sprint 2 | coursework/sprint-2 #805
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
…, interpreted the error and wrote a new and corrected code.
…and modified the code
… has been writtent and implemented
…int 1 and rearranged it into a reusable function toPounds()
…d modified the code.
| suffix = "am"; | ||
| } | ||
|
|
||
| hours = hours % 12 || 12; // convert 0 to 12, 13 to 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.
Can you explain how the expression hours % 12 || 12 convert 0 to 12 and 13 to 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.
Can you explain how the expression
hours % 12 || 12convert 0 to 12 and 13 to 1?
The expression converts 0 to 12, 13 to 1 and soon as it returns the remainder
for eg. taking 12/12 the remainder is 0
similarly if 13 is taken 13/12 , the remainder is 1, the operator || helps us to return the remainder after
a division operation.
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.
My previous question might not be very clear. This is what I would like to find out:
Suppose expr1 and expr2 are some JavaScript expressions.
Can you explain how the expression expr1 || expr2 is evaluated in JavaScript?
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.
My previous question might not be very clear. This is what I would like to find out:
Suppose
expr1andexpr2are some JavaScript expressions. Can you explain how the expressionexpr1 || expr2is evaluated in JavaScript?
In Javascript in evaluating expr1 || expr2... expr1 is first evaluated if, expr1 happens to be false, expr2 gets evaluated.
In our case hours % 12 || 12, if hours %12 = 0 it might be midnight or miday so 12 is returned, other wise.. the remainder is returned. as 1.. 2... 3 ..
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 description is not fully accurate but you probably have a good understanding of what is happening.
…t the function return a number.
…ce(-2) and explained hours = hours % 12 || 12;

Learners, PR Template
Self checklist
Changelist
Completed course works of Sprint 2 from module structuring and testing data
Questions
Questions and blockers will be forwarded to slack.