Two ways will be reasonable.
Using positional parameters:
set "cupcake" "cake" "icecream" "donut" "cocoa" "whipcream" "cookie" "coffee"
for i; do
cd "${DIR}/${i}" || continue
# do something
done
It’s not in custom to store final slash of path in variables, so I use "${DIR}/${i}". Anyway, cd won’t fail at /home//cupcake.
Or using array:
A=( "cupcake" "cake" "icecream" "donut" "cocoa" "whipcream" "cookie" "coffee" )
for i in "${A[@]}"; do
cd "${DIR}/${i}" || continue
# do something
done
Please note, you should use "${A[@]}" to handle spaces properly, not ${A[*]}. || continue interrupts current iteration if cd fails.
Array obviously is more flexible: you can explicitly set a position as you tried to do in your question
A=(
[1]="cupcake"
[7]="cookie"
[2]="cake"
[3]="icecream"
[4]="donut"
[6]="whipcream"
[5]="cocoa"
[8]="coffee"
)
edit any single element later
A[4]="doughnut"
delete any element
unset A[4]
and so on.
#, not with//.