Skip to content

Instantly share code, notes, and snippets.

@krmax44
Created November 9, 2020 08:47
Show Gist options
  • Save krmax44/b70e04bb50070b15d691f27275ff861b to your computer and use it in GitHub Desktop.
Save krmax44/b70e04bb50070b15d691f27275ff861b to your computer and use it in GitHub Desktop.
JS Array functions in Google Spreadsheets
function JSMAP(data, fn) {
return data.map(eval(fn));
}
function JSFILTER(data, fn) {
return data.filter(eval(fn));
}
function JSREDUCE(data, fn, start) {
return data.reduce(eval(fn), eval(start));
}
/*
example usage: replace all Joe's with Jane's
=JSMAP(A1:A20; "(row) => row[0].replace('Joe', 'Jane')")
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment