Skip to content

Conversation

AlekseyPrusevich
Copy link

Copy link
Collaborator

@vramaniuk vramaniuk left a 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 getDistanceBetweenPoints(x1, y1, x2, y2) {
throw new Error('Not implemented');
return Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, improve using Math.hypot

*/
function getRectangleArea(width, height) {
throw new Error('Not implemented');
return width*height;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, spaces between operators

*/
function getAngleBetweenVectors(x1, y1, x2, y2) {
throw new Error('Not implemented');
return Math.acos((x1 * x2 + y1 * y2) / (Math.sqrt(Math.pow(x1, 2) + Math.pow(y1, 2) ) * Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2))));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can improve it using Math.hypot

*/
function getParallelipidedDiagonal(a,b,c) {
throw new Error('Not implemented');
return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) + Math.pow(c, 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, use Math.hypot

Comment on lines +65 to +67
return (+year % 4 != 0) ? false :
(+year % 100 != 0) ? true :
(+year % 400 != 0) ? false : true;
Copy link
Collaborator

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 removeFalsyValues(arr) {
throw new Error('Not implemented');
return arr.filter(arr => Boolean(arr) == true );
Copy link
Collaborator

Choose a reason for hiding this comment

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

arr is unsuatable name in this case , because originally callback may contain el,idx,arr
arr.filter(callback(element[, index, [array]])[, thisArg])

*/
function get3TopItems(arr) {
throw new Error('Not implemented');
return arr.splice(-3).reverse();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It will not work if initial array is not sorted. Please, make the solution more universal. Add sort method

throw new Error('Not implemented');
let count = 0;
arr.map(function(element) {
if (typeof element == "number" && element > 0)
Copy link
Collaborator

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)"

throw new Error('Not implemented');
let count = 0;
arr.map((element) => {
if (Boolean(element) == false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (!element) wiil also work
Please, see https://javascript.info/logical-operators

Comment on lines +453 to +466
let str = '';
arr.map((element, index) => {
if (index + 1 != arr.length)
{
str = str + element + ',';
}
else
{
str = str + element;
}
return element;
});

return str;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, solve it using Array.prototype.join method

@vramaniuk vramaniuk marked this pull request as draft August 24, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants