Skip to main content
added 19 characters in body
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ andfirst, and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeatyou write the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);
 

ActuallyOn closer look, the entire stats method is about deriving Mx and My by applying the exact same sequence of operations on grid and tgrid, respectively. Instead of writing all those non-trivial steps twice, it would be better to move the common logic to a helper function with no duplicated code, so that you can rewrite as:

var Mx = helper(grid),
    My = helper(tgrid);

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Actually the entire stats method is about deriving Mx and My by applying the exact same sequence of operations on grid and tgrid, respectively. Instead of writing all those non-trivial steps twice, it would be better to move the common logic to a helper function with no duplicated code, so that you can rewrite as:

var Mx = helper(grid),
    My = helper(tgrid);

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ first, and make the suggested corrections.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: you write the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);
 

On closer look, the entire stats method is about deriving Mx and My by applying the exact same sequence of operations on grid and tgrid, respectively. Instead of writing all those non-trivial steps twice, it would be better to move the common logic to a helper function with no duplicated code, so that you can rewrite as:

var Mx = helper(grid),
    My = helper(tgrid);
added 389 characters in body
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Actually the entire stats method is about deriving Mx and My by applying the exact same sequence of operations on grid and tgrid, respectively. Instead of writing all those non-trivial steps twice, it would be better to move the common logic to a helper function with no duplicated code, so that you can rewrite as:

var Mx = helper(grid),
    My = helper(tgrid);

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Actually the entire stats method is about deriving Mx and My by applying the exact same sequence of operations on grid and tgrid, respectively. Instead of writing all those non-trivial steps twice, it would be better to move the common logic to a helper function with no duplicated code, so that you can rewrite as:

var Mx = helper(grid),
    My = helper(tgrid);
added 220 characters in body
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);

Sloppy code

This code is extremely sloppy, making it very hard to review. Next time, before posting here, please paste it on http://jshint.com/ or http://jslint.com/ and make the suggested corrections first.

Don't repeat yourself

Copy-pasting code is a very dangerous practice. Don't do it. For example:

var dx = cx.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) }),
    dy = cy.map(function(a){ return a.map(function(_, i){return a[i]-a[i-1]}).slice(1, a.length) });

You do this in many other places too: repeat the same anonymous function twice. Give the function a nice, descriptive name, make it nicely indented and readable, and rewrite the two map calls in terms of it. For example:

// note: try to give this a more descriptive name than "mapper"
function mapper(a) {
    return a.map(function(_, i) { return a[i] - a[i-1] }).slice(1, a.length)
}
var dx = cx.map(mapper),
    dy = cy.map(mapper);
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396
Loading