The following code examines the content of inputData.body
for a 32-character string match, and - to the best of my understanding - places any matches in an array.
// stores an array of any length (0 or more) with the matches
var matches = inputData.body.match(/\b[\w-]{32}\b/g)
// the .map function executes the nameless inner function once for each element of the array and returns a new array with the results
return matches.map(function (m) { return {str: m} })
I now need the code to return something in the case of no matched expressions, eg. the string "false"
.
I wasn't able to get this addition to work...
// stores an array of any length (0 or more) with the matches
var matches = inputData.body.match(/\b[\w-]{32}\b/g)
if (matches == null){
return 'false'
}
// the .map function executes the nameless inner function once for each element of the array and returns a new array with the results
return matches.map(function (m) { return {str: m} })
How should I go about conditionally returning something in the event of emptiness?