Skip to content

Conversation

@AnastasiyaSantalova
Copy link

No description provided.


//add new separator between words
return arrOfLetters.reduce(function(acc, word) {
return acc + sp + word;
Copy link

Choose a reason for hiding this comment

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

...at last merge all the words(Use separator space) and return it

It won't actually do that exactly.

Choose a reason for hiding this comment

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

Actually, I don't understand, what do you mean

Copy link

@svvald svvald Aug 15, 2019

Choose a reason for hiding this comment

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

Well, in the final string words containing your custom separator should be separated by whitespaces itself like (mind the gap) H.e.l.l.o w.o.r.l.d, but in your case it will be H.e.l.l.o.w.o.r.l.d since you use the same separator to divide words itself

Choose a reason for hiding this comment

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

Exactly) Fixed!

});

//add new separator between words
return arrOfLetters.join(sp);
Copy link

Choose a reason for hiding this comment

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

As well as this one.


function stringExpansion(string) {

var repeatSimbol = 1;
Copy link

Choose a reason for hiding this comment

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

Here and below typo in symbol

// FUNCTION 2: convertation hash to array (via entries)

function convert (hash) {
return Object.entries(hash);
Copy link

Choose a reason for hiding this comment

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

Object.entries is a part of ES6+
However I see that you have ES5 version below so it's just a tip for you to be aware of in case you will maintain legacy code

Choose a reason for hiding this comment

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

Yes, I know, I recognized it when function was written and decided to save both variants


// check what kind of separator sring has

str.search('-')>0 ? sep = '-' : sep = '_';
Copy link

Choose a reason for hiding this comment

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

Please use whitespaces around arithmetic, comparison and assignment operators here and below

Choose a reason for hiding this comment

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

Ok!


var arr = str.split(sep).map(function(word, ind) {

if (ind!=0) {
Copy link

Choose a reason for hiding this comment

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

It's a good practice to always use === and !== operators to avoid implicit type coercion


var repeatSimbol = 1;

return string.split("").reduce(function(acc,simbol,ind,arr) {
Copy link

Choose a reason for hiding this comment

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

Add whitespaces between function arguments


// FUNCTION 1: returns phrase with determined separator (via reduce)

function splitAndMerge (str, sp) {
Copy link

Choose a reason for hiding this comment

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

Function's name usually is not separated from parentheses with whitespace


// check what kind of separator sring has

str.search('-')>0 ? sep = '-' : sep = '_';
Copy link

Choose a reason for hiding this comment

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

You can take a look at regular expressions, you could use them in split method describing all the symbols you want to match in one expression

countDown(2);


// FUNCTION 10: prototipe for bind()
Copy link

Choose a reason for hiding this comment

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

PrototYpe :)

Choose a reason for hiding this comment

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

Exactly!)


// if the symbol is number

if (isNaN(symbol)==false) {
Copy link

Choose a reason for hiding this comment

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

Use triple equals operator + surround it by whitespaces

return b - a;
}

var numbers=[];
Copy link

Choose a reason for hiding this comment

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

Whitespaces

return a - b;
}

var numbers=[];
Copy link

Choose a reason for hiding this comment

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

Whitespaces


function sum() {

var sumOfArgs=0;
Copy link

Choose a reason for hiding this comment

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

Whitespaces

function sum1() {

var i = arguments.length - 1;
var newArguments=[];
Copy link

Choose a reason for hiding this comment

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

Whitespaces


return function () {

var innerArgs=[];
Copy link

Choose a reason for hiding this comment

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

Whitespaces

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