beautiful-arrangement-ii - JS Solution
\n# Code\njavascript []\n/**\n * @param {number} n\n * @param {number} k\n * @return {number[]}\n */\nvar constructArray = function(n, k) {\n    let ans = new A
\n# Code\n```javascript []\n/**\n * @param {number} n\n * @param {number} k\n * @return {number[]}\n */\nvar constructArray = function(n, k) {\n    let ans = new Array(n)\n    for (let i = 0, a = 1, z = k + 1; i <= k; i++)\n        ans[i] = i % 2 ? z-- : a++\n    for (let i = k + 1; i < n;)\n        ans[i] = ++i\n    return ans\n    \n};\n```
['JavaScript']