Your script gets wrapped in an implicit function; that’s what the function evaluateTag(input1, input2) { and } blocks are above and below the text editor. The script you have defined here is defining an inner function and not returning anything, which is why you get an Undefined out of it.