Skip to content
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

Merged
merged 4 commits into from
Jan 15, 2020
Merged

Conversation

johnsonsirv
Copy link
Owner

Request to Merge <=== Live Link

In this PR I achieved the following: 🚀

1. Preparation

  • Created a new logic folder inside src and initialize two javascript files there: calculate.js and operate.js.
  • Added the Big package to your project dependencies.

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!! 😎

@johnsonsirv johnsonsirv added the enhancement New feature or request label Jan 14, 2020
@johnsonsirv johnsonsirv added this to the Logic 1 (Basic Logic) milestone Jan 14, 2020
Copy link

@shloch shloch left a 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 😊

Comment on lines 3 to 5
const calculate = (data, btnName) => {
const temp = data;
const calcOperations = {
Copy link

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

Copy link

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

Copy link
Owner Author

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.

Copy link

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 🙂

Copy link
Owner Author

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

Comment on lines 8 to 10
case '÷':
result = n1.div(n2);
break;
Copy link

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 😊

Copy link
Owner Author

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

Copy link

@bolah2009 bolah2009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a 👍🏾 from me!

✔️ Approved!

Good luck with your next milestones. 🌟

Cheers
Bola

@johnsonsirv johnsonsirv merged commit addbc86 into develop Jan 15, 2020
@johnsonsirv johnsonsirv deleted the app-logic branch July 25, 2020 22:15
@johnsonsirv johnsonsirv restored the app-logic branch July 25, 2020 22:15
@johnsonsirv johnsonsirv deleted the app-logic branch July 25, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants