Is there a another way to do this? I'm using the underscore js lib here, which is where the _. comes from. I'm used to this sort of procedure to format strings in python and I'd like something simple for JavaScript without doing + + + + all the time. This works, but it feels like I reinvented the wheel.
function foo (iterable, string) { var s = iterable.shift(); string = string.replace("%s",s); return _.isEmpty(iterable) ? string : foo(iterable,string); }; foo(['sam','green','ham'],"%s likes %s eggs and %s."); "sam likes green eggs and ham."