Home > Mobile >  Apps Script: Return Array Item
Apps Script: Return Array Item

Time:01-08

Well… I guess I better ask for some help on this one:

const name = “alain”;
const arr = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"];

All I wanna do is this: Search for the email-address starting with “alain” and return that email-address to me as a variable that I can use in other functions.

Any idea how this could be achieved?

Thanks:)

CodePudding user response:

const address = arr.find(element => element.startsWith(name))
  •  Tags:  
  • Related