Chalarangelo/30-seconds-of-code

CSVToArray will return an empty item for documents ending with \n

chepo92 opened this issue · 2 comments

https://github.com/30-seconds/30-seconds-of-code/blob/master/snippets/CSVToArray.md

CSVToArray('a,b\nc,d\n'); // [ [ 'a', 'b' ], [ 'c', 'd' ], [ '' ] ]

The same problem will arise if the document is starting with \n as well.

Answerig myself, .filter(Boolean) will get rid of them, getting those nulls/empty may sometimes be the intended behaviour.