scratch = scratch + "<a href....";
you need to use the built in += operator, thusly:
scratch += "<a href....";
The function in question had the first approach 12 times. Using the built in += operator I was able to reduce each statement by 9 characters. That reduces the function by 108 characters overall.
So the lesson is use built in functionality because little things can add up.