javascript-tutorial / javascript-tutorial/en.javascript.info
Array Task Solution Clarification
- Dominant language
- HTML
- Stars
- 25.5k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
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'
}
`
Contributor guide
No contributing guide indexed for this repository
Research direction
Open the linked javascript.info Array tasks page and inspect the second task, “Array operations,” alongside its provided solution. Check that the solution handles the stated odd-length requirement and replaces the middle value as described. Done means the tutorial solution matches the instruction for arrays of odd length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100