initial foreach lop exercise
Added conditional.