I believe this is the actual way

I believe document.write in js is more analogous to printf in c