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. Roman Tarasenko #845

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

Conversation

RomanTarasenko
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!

@@ -22,7 +22,7 @@
* '', 'bb' => 'bb'
*/
function concatenateStrings(value1, value2) {
throw new Error('Not implemented');
return value1+value2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, try to follow these rules https://javascript.info/coding-style
spaces between operators

@@ -73,7 +76,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(((x2-x1)*(x2-x1)) +((y2-y1)*(y2-y1)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try to improve using Math.hypot

@@ -160,7 +164,7 @@ function parseNumberFromString(value) {
* 1,2,3 => 3.741657386773941
*/
function getParallelipidedDiagonal(a,b,c) {
throw new Error('Not implemented');
return Math.sqrt((a*a + b*b) + c*c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try to improve using Math.hypot

@@ -23,7 +23,11 @@
* [0, 1, 2, 3, 4, 5], 5 => 5
*/
function findElement(arr, value) {
throw new Error('Not implemented');
if (arr.find((el) => el === value)) {
return arr.indexOf(value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just this line will work as a solution

Comment on lines +78 to +84
let arrPos = [];
arr.map((el)=>{
if(el > 0){
arrPos.push(el)
}
});
return arrPos;
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 Array.prototype.filter method here

function removeFalsyValues(arr){
let newArr = [];
arr.map((el) =>{
if (Boolean(el) !== false){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant condition. Just if (el) { will work
Please, see https://javascript.info/logical-operators

Comment on lines +327 to +331
let newArr = arr.reverse();
if (arr.length > 3) {
newArr.length = 3;
}
return newArr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If test cases had unsorted array, it woudn't work.
To prevent errors in case tests will reworked, please add sort method in place of reverse

let newArr = [];
if (arr.length){
arr.map((el) =>{
if (Boolean(el) === 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 (!el) will work
Please, see https://javascript.info/logical-operators

let newArr = [];
arr.map((el) =>{
let i = newArr.find(item => item === el);
if (i === undefined){
Copy link
Collaborator

Choose a reason for hiding this comment

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

!newArr.includes(el) will work. And remove line with find

@vramaniuk vramaniuk marked this pull request as draft August 21, 2020 19:11
@vramaniuk
Copy link
Collaborator

And try to resolve conflicting files. It's very significant in real project

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