1

I'm using dashing-js and trying to do the following

var d3 = require('d3');

Whitout success and I don't get any error messages more than that my jobs aren't running at all.

Any way I'm only want to make use of the d3.max and d3.min functions. Do anyOne of you perhaps know where I could find the javascript implementation of those 2 functions so I can just cop n paste them at the bottom of my js job file and don't have to import d3 at all?

Thanks alot in advance.

user1825441
  • 507
  • 9
  • 13
  • So you have an array and you want the max and min values within the array? This question: http://stackoverflow.com/q/1669190/4026797 should have an answer for you -- Possible duplicate, but I guess there's no "selected answer." This answer in particular looks promising http://stackoverflow.com/a/1669222/4026797. – McTalian Oct 23 '14 at 17:28
  • if you're using underscore/lodash they also have min/max implemented – explunit Oct 23 '14 at 18:23

1 Answers1

0

To find the minimum value of an array arr:

Math.min.apply(this,arr);

Similary, for maximum value

Math.max.apply(this,arr);

You don't need a library or even a function.

Stephen Thomas
  • 13,843
  • 2
  • 32
  • 53