Array Task Solution Clarification
Data Types > Arrays > Tasks > Second Task 'Array operations.' https://javascript.info/array#tasks
Instruction 3 states:
"Replace the value in the middle by "Classics". Your code for finding the middle value should work for any arrays with odd length."
This specifies that we should replace the middle value, and that our code should work for any arrays with an odd length.
The solution provided does not include a condition, and will always replace a value in an array, regardless of it's length.
Consider adding:
if (styles.length % 2 !== 0) { styles[Math.floor(styles.length / 2)] = 'Classics' }
my opinion I guess the "odd len" is just to avoid the hardcoded a[1]= the point is basic array methods
I'd replace "odd" by "any", I dont see the "even len ambiguity" as an issue here
I'd replace "odd" by "any", I dont see the "even len ambiguity" as an issue here
That makes sense. I took the instructions in a "rules as written" way, but your interpretation is likely how it was intended.