Created
November 9, 2020 08:47
-
-
Save krmax44/b70e04bb50070b15d691f27275ff861b to your computer and use it in GitHub Desktop.
JS Array functions in Google Spreadsheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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