Re:Show HN: Alter – convert text/code to an image
by nkkollaw on Saturday November 26, 2016 @04:44AM
(#13042729)
How would you have written that?
[ Parent
| on HN ]
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, '')`