Skip to content
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

#1 4 task aleksey prusevich #908

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

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!

@@ -73,7 +73,7 @@ function getAverage(value1, value2) {
* (-5,0) (10,-10) => 18.027756377319946
*/
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

@@ -22,7 +22,7 @@
* 5, 5 => 25
*/
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

@@ -111,7 +111,7 @@ function getLinearEquationRoot(a, b) {
* (0,1) (1,2) => 0
*/
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

@@ -160,7 +160,7 @@ function parseNumberFromString(value) {
* 1,2,3 => 3.741657386773941
*/
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)"

@@ -102,7 +106,7 @@ function getArrayOfStrings(arr) {
* [ false, 0, NaN, '', undefined ] => [ ]
*/
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])

@@ -286,7 +315,7 @@ function propagateItemsByPositionIndex(arr) {
* [ 10, 10, 10, 10 ] => [ 10, 10, 10 ]
*/
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