Reference no: EM133234666
A code in swift programming language
Create a constant and assign a color to it - the color should be a string.
Example: blue
Create an array of elements and instantiate the array with colors (strings) - 5 or more colors.
Example: (red, orange, blue, black, yellow, brown)
Use a loop to iterate through the array and check each color to see if it matches the color of your constant.
Print a message to the console
If a color matches the constant Print "Found a match at position X in the array" - X must be the actual position in the array.
If there are no matches in the array Print "No colors match"
(EXTRA) Account for multiple matches and indicate how many matches there are and at what positions in a single statement in the console
Example: Constant: red Array(red, green, red, orange, red, black, red, red)
Output: There were 5 color matches at positions 0,2,4,6,7 in the array.