Skip to content

FindLCM: Improve code readablility #985

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

Merged
merged 3 commits into from
Apr 20, 2022

Conversation

CarlosZoft
Copy link
Member

Welcome to the JavaScript community

Open in Gitpod know more

Describe your change:

  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.

Copy link
Collaborator

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

I like the return; there already is a similar PR (https://github.com/TheAlgorithms/Javascript/pull/951/files) concerning the Math.max instead of the if-else. Again, please revert the change that relies on JS truthiness and use explicit comparison against zero (=== 0) as it is more readable and less error-prone in general.

(Technically the condition could even be shortened further as !((lcm % num1) || (lcm % num2)) according to De Morgan's law, but that sure would be unreadable ;) )

@appgurueu appgurueu added feature Adds a new feature changes required This pull request needs changes beginner-friendly Easy to implement labels Apr 20, 2022
@CarlosZoft
Copy link
Member Author

true, i will fix this

@CarlosZoft
Copy link
Member Author

Fixed it. But what you think, i remove math.max approached in another PR or not?

Copy link
Collaborator

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

Looks fine now. LGTM.

@raklaptudirm raklaptudirm changed the title fix: improving code readability FindLCM: Improve code readablility Apr 20, 2022
@raklaptudirm raklaptudirm merged commit 8fc5390 into TheAlgorithms:master Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner-friendly Easy to implement changes required This pull request needs changes feature Adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants