-
Notifications
You must be signed in to change notification settings - Fork 0
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
Pull Request: Basic App Logic 1 (Milestone 4) #4
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.
Hello @johnsonsirv
It's all good your work. I like what you did
[CHANGE REQUIRED]
i just wish you to CLEAN-UP your code file "src/logic/calculate.js"
, by removing the superficial shallow object copy and then, destructure and use your variables simply (comments below): 😊😊
Then file for last re-review..
Happy coding 😊
src/logic/calculate.js
Outdated
const calculate = (data, btnName) => { | ||
const temp = data; | ||
const calcOperations = { |
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 dont know why you need
const temp = data;
data
is an object, that will copy by reference, so basically
temp.total
and data.total
will be the same thing
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.
Also you need to destructure data
here (something like) :
let { total, next, operation } = data;
so that you get to be using total
simply, instead of data.total
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 am not exactly sure if destructuring (copying into new variables) will help me directly modify the data object, as stated in the milestone.
I made a shallow copy so I can mutate the data object directly. I am open to better ways to achieve this.
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.
You can manipulate individual variables, and if you need the object at the end, then you can get it back by making the object 🙂
If I want var1
and var2
as object , I just make the object {var1, var2}
Just to say it's doable 🙂
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.
Aha !!! 😄 I see your perspective. Didn't think about that earlier.
Thanks for the hint @shloch
src/logic/operate.js
Outdated
case '÷': | ||
result = n1.div(n2); | ||
break; |
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.
Dont forget to manage division by ZERO on next milestone with this, because it will through an error 😊
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.
👍 OMG. Thank you @shloch for this pointer
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.
Request to Merge <=== Live Link
In this PR I achieved the following: 🚀
1. Preparation
2. Implemented the calculate.js module
3. Implemented the operate.js module
4. Added calculate.js to the App component
Import the calculate function. temporarily disabled the eslint-no-unused-var for this line
For this Milestone, the actual calculator operation is incomplete. The
display
shows each button you click. In the next milestone, I will complete the calculation/operation and have a fully functional calculator app.PS: This is a Solo Project
Thanks in advance. Happy Reviewing!! 😎