-
Notifications
You must be signed in to change notification settings - Fork 188
#1-4 Task. Stenko Yaroslav #906
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
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!
task/02-numbers-tasks.js
Outdated
*/ | ||
function getDistanceBetweenPoints(x1, y1, x2, y2) { | ||
throw new Error('Not implemented'); | ||
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 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.
Please, improve code using Math.hypot
task/02-numbers-tasks.js
Outdated
let result = -b / a; | ||
return result === 0 ? 0 : result; |
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 just return -b / a
because
-0 === 0 (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.
We can just
return -b / a
because
-0 === 0 (true)
Yes, I have checked this when I was doing the task, but when I return -b / a it says that 0 was expected but actually got -0 and test fails.
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.
But we have successful tracis build for such solution here:
#928
https://travis-ci.org/github/AleshaKolesnikov/js-assignments/builds/719550067
Please, try to find differences.
May be node versions, travis.yml
task/02-numbers-tasks.js
Outdated
let firstVectorMagnitude = Math.sqrt((Math.pow(x1, 2)) + Math.pow(y1, 2)); | ||
let secondVectorMagnitude = Math.sqrt((Math.pow(x2, 2)) + Math.pow(y2, 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.
Please, improve code using Math.hypot
task/02-numbers-tasks.js
Outdated
let result = 0; | ||
for(let i = 0; i < value.toString().length; i++){ | ||
result = value % 10; | ||
} | ||
return result; |
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 solve this task without loops.
(last digit of any decimal number is remainder of division by 10)
5ad9b2a
to
0f69438
Compare
3646afc
to
cb9171e
Compare
Closing the PR as accepted! Thanks! |
https://travis-ci.com/github/StYaroslav/js-assignments/builds/179422955