Skip to content

Conversation

@tkkdev
Copy link

@tkkdev tkkdev commented Jul 17, 2019

No description provided.

function largest(arr)
{
let numbers = [];
for(let i = 0; i < arguments.length; ++i)

Choose a reason for hiding this comment

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

what's the propose of transforming arguments to real array? you didn't use any of array methods.

/* largest */
function largest(arr)
{
let numbers = [];
Copy link

@milkiwayRN milkiwayRN Jul 18, 2019

Choose a reason for hiding this comment

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

let is the part of ES6/ES2015 - it's forbidden for this hw

@@ -0,0 +1,10 @@
/* reverseString */
function reverseString(str){
str = str.split(' ');

Choose a reason for hiding this comment

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

try to not modify arguments of function - in some cases it could lead to unexpected side effects in your apps

{
let numbers = [];
for(let i = 0; i < arguments.length; ++i)
numbers[i] = arguments[i];

Choose a reason for hiding this comment

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

the same as for largest function

function splitAndMerge(str, sp){
let wrds = str.split(' ');
const chars = [];
for(let i = 0; i < wrds.length; ++i)

Choose a reason for hiding this comment

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

don't use for, if without brackets - it decreases readability of your code

/* splitAndMerge */
function splitAndMerge(str, sp){
let wrds = str.split(' ');
const chars = [];
Copy link

@milkiwayRN milkiwayRN Jul 18, 2019

Choose a reason for hiding this comment

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

maybe something like wordsWithSP or modifiedWords? - chars is confusing name

/* sum */
function sum()
{
return arguments.length === 0? 0 : arguments[0] + sum.apply(0, Array.prototype.slice.call(arguments, 1));

Choose a reason for hiding this comment

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

Actually, I'm ok with that solution, but maybe better to use here reduce instead of recursion?

Choose a reason for hiding this comment

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

oh, ignore this comment - I didn't see that recursion is the requirement

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