-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Test fix #2
Conversation
chapter1/index.js
Outdated
|
||
console.log(arr[4]) | ||
Formulas.sinTimesCos = function(a){ | ||
return Math.sin(a)*Math.cos(a); |
There was a problem hiding this comment.
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.
chapter1/index.js
Outdated
var i; | ||
var j; | ||
var p; | ||
for(i = 0; i < Object.keys(obj).length; i++){ |
There was a problem hiding this comment.
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.
chapter1/index.js
Outdated
var i; | ||
var j; | ||
var p; | ||
for(i = 0; i < Object.keys(obj).length; i++){ |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
chapter1/index.js
Outdated
} | ||
Formulas.squareArrayValues = function(a){ | ||
var newArr = a; | ||
for (var i = 0; i < newArr.length; i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not iterate over
a
? - Why not giving proper names like
arrayToBeSquared
} | ||
|
||
Formulas.sortArray = function(a){ | ||
return a.sort(Formulas.sortNumbers) |
There was a problem hiding this comment.
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.
chapter1/index.js
Outdated
console.log('Get some air in your lungs!'); | ||
blaFunction(); | ||
console.log('Now you can rest!') | ||
Formulas.sortNumbers = function(a,b){ |
There was a problem hiding this comment.
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.
Fixed tests by adding function for each tests.
P.S. I plan to revisit the function for searching object value by key.