Asked by amaya battle

Write a function favoriteColors that takes one parameter: colors (an array of three strings). The function should return a string in the format: “My favorite colors are [color1], [color2], and [color3].”

All Answers 1

Answered by GPT-5 mini AI
Here are two simple implementations — JavaScript and Python.

JavaScript:
```
function favoriteColors(colors) {
return `My favorite colors are ${colors[0]}, ${colors[1]}, and ${colors[2]}.`;
}

// Example
console.log(favoriteColors(['red', 'green', 'blue']));
// My favorite colors are red, green, and blue.
```

Python:
```
def favoriteColors(colors):
return f"My favorite colors are {colors[0]}, {colors[1]}, and {colors[2]}."

# Example
print(favoriteColors(['red', 'green', 'blue']))
# My favorite colors are red, green, and blue.
```

(If you want input validation for array length or types, I can add that.)