Skip to content

Test fix #2

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

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

Test fix #2

wants to merge 6 commits into from

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