[JavaScript] One loop solution
\nconst sortArrayByParityII = arr => {\n    let res = []\n    let evenIndex = 0\n    let oddIndex = 1\n    for (let i = 0; i < arr.length; i++) {\n        if (a
```\nconst sortArrayByParityII = arr => {\n    let res = []\n    let evenIndex = 0\n    let oddIndex = 1\n    for (let i = 0; i < arr.length; i++) {\n        if (arr[i] % 2 === 0) {\n            res[evenIndex] = arr[i]\n            evenIndex = evenIndex + 2\n        } else {\n            res[oddIndex] = arr[i]\n            oddIndex = oddIndex + 2\n        }\n    }\n    return res\n}\n```
['JavaScript']