You are viewing a single comment's thread. Return to all 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(" "));
}
Seems like cookies are disabled on this browser, please enable them to open this website
Zig Zag Sequence
You are viewing a single comment's thread. Return to all 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(" "));
}