Skip to content

#1 4 task aleksey prusevich - #908

Draft
AlekseyPrusevich wants to merge 11 commits into
ilya4321:masterfrom
AlekseyPrusevich:#1-4-Task-Aleksey-Prusevich
Draft

#1 4 task aleksey prusevich#908
AlekseyPrusevich wants to merge 11 commits into
ilya4321:masterfrom
AlekseyPrusevich:#1-4-Task-Aleksey-Prusevich

Conversation

@AlekseyPrusevich

Copy link
Copy Markdown

@vramaniuk vramaniuk left a comment

Copy link
Copy Markdown
Collaborator

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!

Comment thread task/02-numbers-tasks.js
*/
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
Copy Markdown
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

Comment thread task/02-numbers-tasks.js
*/
function getRectangleArea(width, height) {
throw new Error('Not implemented');
return width*height;

Copy link
Copy Markdown
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

Comment thread task/02-numbers-tasks.js
*/
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
Copy Markdown
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

Comment thread task/02-numbers-tasks.js
*/
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
Copy Markdown
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 thread task/03-date-tasks.js
Comment on lines +65 to +67
return (+year % 4 != 0) ? false :
(+year % 100 != 0) ? true :
(+year % 400 != 0) ? false : true;

Copy link
Copy Markdown
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)"

Comment thread task/04-arrays-tasks.js
*/
function removeFalsyValues(arr) {
throw new Error('Not implemented');
return arr.filter(arr => Boolean(arr) == true );

Copy link
Copy Markdown
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])

Comment thread task/04-arrays-tasks.js
*/
function get3TopItems(arr) {
throw new Error('Not implemented');
return arr.splice(-3).reverse();

Copy link
Copy Markdown
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

Comment thread task/04-arrays-tasks.js
throw new Error('Not implemented');
let count = 0;
arr.map(function(element) {
if (typeof element == "number" && element > 0)

Copy link
Copy Markdown
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)"

Comment thread task/04-arrays-tasks.js
throw new Error('Not implemented');
let count = 0;
arr.map((element) => {
if (Boolean(element) == false)

Copy link
Copy Markdown
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 thread task/04-arrays-tasks.js
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
Copy Markdown
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