News for hackers. Stuff that matters.
Re:Show HN: Alter – convert text/code to an image by gumoro on Saturday November 26, 2016 @06:53AM (#13043054)
For point 1 I would use "reduce":

  lines.reduce((longest, line) => (longest.length > line.length) ? longest : line, "")
https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...

EDIT: sorry, initial code returned length, not line itself

Re:Show HN: Alter – convert text/code to an image by nunull on Saturday November 26, 2016 @06:54AM (#13043060)
This returns the length, not the line itself.

Edit: `lines.reduce((line, line_) => line_.length > line.length ? line_ : line, '')`

Re:Show HN: Alter – convert text/code to an image by gumoro on Saturday November 26, 2016 @06:58AM (#13043079)
Thanks, edited.
Re:Show HN: Alter – convert text/code to an image by paradite on Saturday November 26, 2016 @01:53PM (#13045275)
It is a good use of reduce (accumulate as I call it), but maybe slightly overkill for this case compared to a simple iteration or a max function.