Skip to content

Conversation

@levnikan
Copy link

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


console.log(arr[4])
Formulas.sinTimesCos = function(a){
return Math.sin(a)*Math.cos(a);
Copy link
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.

var i;
var j;
var p;
for(i = 0; i < Object.keys(obj).length; i++){
Copy link
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.

var i;
var j;
var p;
for(i = 0; i < Object.keys(obj).length; i++){
Copy link
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.

}

Formulas.parseJSON = function(a){
return JSON.parse(a);
Copy link
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.

}

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

Choose a reason for hiding this comment

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

Here too.

}
Formulas.squareArrayValues = function(a){
var newArr = a;
for (var i = 0; i < newArr.length; i++){
Copy link
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

}

Formulas.sortArray = function(a){
return a.sort(Formulas.sortNumbers)
Copy link
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.

console.log('Get some air in your lungs!');
blaFunction();
console.log('Now you can rest!')
Formulas.sortNumbers = function(a,b){
Copy link
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