-
-
Notifications
You must be signed in to change notification settings - Fork 71
WESTMIDLANDS-ITP-JAN|SEGUN FOLAYAN|DATA FLOWS|BOOK-LIBRARY #208
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?
WESTMIDLANDS-ITP-JAN|SEGUN FOLAYAN|DATA FLOWS|BOOK-LIBRARY #208
Conversation
debugging/book-library/script.js
Outdated
@@ -76,7 +84,7 @@ function render() { | |||
changeBut.className = "btn btn-success"; | |||
wasReadCell.appendChild(changeBut); | |||
let readStatus = ""; | |||
if (myLibrary[i].check == false) { | |||
if (myLibrary[i].check == true) { |
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 think of a way to rewrite lines 87-91 in order to reduce repetition?
- The value within myLibrary[i].check will hold either true or false.
- Can you use a ternary operator to achieve the same result in one line of code
The syntax of the ternary operator is like this:
condition ? trueExpression : falseExpression.
If the condition evaluates to true, the expression after the ? is executed; otherwise, the expression after the : is executed.
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.
readStatus = myLibrary[i].check ? "Yes" : "No";
I have replaced with this line of code.
Thank 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.
Your PR looks good 👍
Here are a few change requests that will make it even better:
-
Can you review all of the places that you declared a variable with 'let'? In general, you will mostly always use const (and this should be your default). If you need to reassign a value to the variable, then you would use let. Here is a video you can watch: https://youtu.be/RE6qf3As-XU?si=_YaiEPeBC5Cx_j56
-
The 4 variables on lines 24-27 are currently declared as global variables. However, they are only used within the submit function.
Can modify your code so that they are no longer global variables and are declared as local variables?
Making this change means the variables won't be created until they are needed within the submit function. This makes the code cleaner and more maintainable!
https://www.w3schools.com/js/js_scope.asp
Hello,
|
Thank you for your prompt and timely review. |
Learners, PR Template
Self checklist
Changelist
BOOK LIBRARY PROJECT PR
Questions
Ask any questions you have for your reviewer.