-
Notifications
You must be signed in to change notification settings - Fork 189
#6Task.Maria Larchenko #299
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?
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!
function isTriangle(a, b, c) { | ||
if (a + b > c && b + c > a && c + a > b) { | ||
return true; | ||
} else return false; |
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.
We can return (a + b > c) && (a + c > b) && (c + b > a) with the sam result
Please, improve logic for consistency
https://javascript.info/logical-operators
} else if (rigthB < rect1.left && bottomB < rect1.top) { | ||
return false; | ||
} | ||
else return 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.
Actually we don't need to use 'else' at the last statement (just return true)
const diff = Math.pow((circle.center.x - point.x), 2) + Math.pow((circle.center.y - point.y), 2); | ||
if (diff < Math.pow(circle.radius, 2)) { | ||
return true; | ||
} else return false; |
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.
https://javascript.info/logical-operators
We can just return diff < Math.pow(circle.radius, 2)
@@ -166,7 +202,7 @@ function isInsideCircle(circle, point) { | |||
* 'entente' => null | |||
*/ | |||
function findFirstSingleChar(str) { | |||
throw new Error('Not implemented'); | |||
return Array.from(str).filter(s => Array.from(str).filter(s2 => s2 == s).length == 1)[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
sometimes ''==' may cause an error
(check at console :
""0"" == 0
and ""0"" === 0)"
@@ -296,7 +353,31 @@ function getDigitalRoot(num) { | |||
* '{[(<{[]}>)]}' = true | |||
*/ | |||
function isBracketsBalanced(str) { | |||
throw new Error('Not implemented'); | |||
if (str.length % 2 != 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
sometimes ''!=' may cause an error
(check at console :
""0"" != 0
and ""0"" !== 0)"
const m2RowsNum = m2.length; | ||
let result = []; | ||
|
||
if (m1ColumnsNum != m2RowsNum) return false; |
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
Done task 6. Link to travis-ci build https://travis-ci.org/github/MariaLarchenko/js-assignments/builds/705744213