Zig Zag Sequence

  • + 0 comments

    There is no code to debug in Javascript but I try to get the result in 3 lines but it did not pass the test.

    function processData(input) { //Enter your code here const arr = input.split('\n')[2].split(' ').map(str => parseInt(str)).sort((a,b) => a - b); const mid = Math.floor(arr.length/2); console.log([...arr.slice(0,mid),...arr.slice(mid).reverse()].map(String).join(" "));

    }