How do I get every single record of an array string substring?
Example:
sourcefiles = ['a.pdf', 'a_ok.pdf', 'a.csv', 'b_ok.csv', 'b.csv', 'c.pdf']
var uniq = [ ...new Set(sourcefiles)]; //I want the output to be: a, b, c
console.log(uniq)
I tried to add substring:
sourcefiles = ['a.pdf', 'a_ok.pdf', 'a.csv', 'b_ok.csv', 'b.csv', 'c.pdf']
var uniq = [ ...new Set(sourcefiles.substring(0,1))];
console.log(uniq)
VM116792:2 Uncaught TypeError: sourcefiles.substring is not a function
at <anonymous>:2:37
How do I get unique records by comparing the first n characters?