Shell: Create a Comma Separated String

I recently needed to generate a string with comma separated values, based on iterating a range of numbers (e.g. we should get the following output where n = 3).
foo-0,foo-1,foo-2
I only had Shell available to me so I couldn’t shell out into Python or Ruby, for example. That means it’s Bash scripting time!

Link: https://dzone.com/articles/shell-create-a-comma-separated-string?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev