ok I am clearly missing something, because this should work (I think).
// this works fine
var xyz = string.format("%d");
// this attempt to create a dynamic format does not
var fmt = ""%d""; // this assigns the string "%d" to the variable - identical to hard coding it
var xyz = string.format(fmt);