I am learning about for
loops. Here is my code:
#!/bin/bash
# states list
states=('New York' 'Arizona' 'Texas')
# script to check which state is cool.
for state in ${states[@]}
do
if [ $state = 'New York' ]
then
echo 'New York is cool'
else
echo 'Arizona rocks'
fi
done
This is my output when I run it:
Arizona rocks
Arizona rocks
Arizona rocks
Arizona rocks
Why is it outputting 4 times and also the wrong answer?