-
Notifications
You must be signed in to change notification settings - Fork 188
#6Task. Sergey Tsvirko #839
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: master
Are you sure you want to change the base?
#6Task. Sergey Tsvirko #839
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.
I'll mark the PR as "Draft", please click "ready for review" when it will be finished. Thank you!
if ((num%3 == 0) && (num%5 == 0)) return 'FizzBuzz'; | ||
if (num%3 == 0) return 'Fizz'; | ||
return (num%5 == 0) ? 'Buzz' : num; |
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.
"operator === is always preferable
sometimes ''==' may cause an error
(check at console :
'0' == 0
and '0' === 0)"
*/ | ||
function isInsideCircle(circle, point) { | ||
throw new Error('Not implemented'); | ||
return circle.radius > Math.sqrt(Math.pow(point.x - circle.center.x, 2) + Math.pow(point.y - circle.center.y, 2)); |
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.
Try to use Math.hypot method
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot
|
||
const isEqualsOne = (element) => element == 1; | ||
let nonRepeatedChar = Array.from(map.keys())[Array.from(map.values()).findIndex(isEqualsOne)]; | ||
return nonRepeatedChar ? nonRepeatedChar : null; |
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.
ternary operator is redundant here
Please, see https://javascript.info/logical-operators
we can return just nonRepeatedChar with the same result
map.set(item, map.get(item)+1); | ||
}) | ||
|
||
const isEqualsOne = (element) => element == 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.
operator === is always preferable
if ((index - 1 == 0) && parity) { | ||
total = changeItem(total); | ||
} | ||
|
||
if ((index %2 == 0) && parity) { |
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.
operator === is always preferable
let matchSet = new Set(vertical); | ||
|
||
JSON.parse(JSON.stringify(position)).reduce(function(total, current, index) { | ||
if (total[position.length-index] != current[position.length-index-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.
operator !== is always preferable
current[position.length-index-1] = ''; | ||
} | ||
|
||
if (position.length-1 == index) matchSet.add(current[0]); |
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.
operator === is always preferable
current[index] = ''; | ||
} | ||
|
||
if (position.length-1 == index) matchSet.add(current[position.length-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.
operator === is always preferable
}) | ||
|
||
JSON.parse(JSON.stringify(position)).reduce(function(total, current, index) { | ||
if (total[index-1] != current[index]) { |
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.
operator !== is always preferable
if (elem == 'X') counterX++; | ||
if (elem == '0') counter0++; | ||
if ((counterX == 3) || (counter0 == 3)) matchSet.add(elem); |
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.
operator === is always preferable
https://travis-ci.com/github/SergeyTsvirko/js-assignments