Skip to content

Test fix#2

Open
levnikan wants to merge 6 commits intodev-tim:masterfrom
levnikan:master
Open

Test fix#2
levnikan wants to merge 6 commits intodev-tim:masterfrom
levnikan:master

Conversation

@levnikan
Copy link
Copy Markdown

Fixed tests by adding function for each tests.
P.S. I plan to revisit the function for searching object value by key.

Comment thread chapter1/index.js Outdated

console.log(arr[4])
Formulas.sinTimesCos = function(a){
return Math.sin(a)*Math.cos(a);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Spacing here. Watch out for good programming style.

Comment thread chapter1/index.js Outdated
var i;
var j;
var p;
for(i = 0; i < Object.keys(obj).length; i++){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

you could use let instead of var here. It behaves more like normal variable from Java.

Comment thread chapter1/index.js Outdated
var i;
var j;
var p;
for(i = 0; i < Object.keys(obj).length; i++){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You could extract Object.keys(obj) to a variable.

Comment thread chapter1/index.js
}

Formulas.parseJSON = function(a){
return JSON.parse(a);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe to reason to wrap this stuff in function.

Comment thread chapter1/index.js
}

Formulas.pushToArray = function(a,b){
return a.push(b);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Here too.

Comment thread chapter1/index.js Outdated
}
Formulas.squareArrayValues = function(a){
var newArr = a;
for (var i = 0; i < newArr.length; i++){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  1. Why not iterate over a?
  2. Why not giving proper names like arrayToBeSquared

Comment thread chapter1/index.js
}

Formulas.sortArray = function(a){
return a.sort(Formulas.sortNumbers)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Not move one-liners to methods unless there is some specific logic there.

Comment thread chapter1/index.js Outdated
console.log('Get some air in your lungs!');
blaFunction();
console.log('Now you can rest!')
Formulas.sortNumbers = function(a,b){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is a sortFunction that will be applied to the array.

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