javascript
\n\n\nvar constructArray = function(n, k) {\n\n    let a = Array.from(Array(n).keys()).map( a => a + 1);\n    if(k ===1) return a;\n\n    const len = a.length;\
\n\n```\nvar constructArray = function(n, k) {\n\n    let a = Array.from(Array(n).keys()).map( a => a + 1);\n    if(k ===1) return a;\n\n    const len = a.length;\n\n    for(let i=2;i<= k;i++) {\n        let x = a.slice( len - i + 1 ,len);\n        let y = a.slice(0, len - i + 1);\n        a = [...y.reverse(),...x];\n    }\n    return a;\n\n};\n```
[]