reversing array

Run Settings
LanguageJavaScript
Language Version
Run Command
//also use arr.reverse function processData(input) { let arr = input.split("\n")[1].split(" ").map(Number) let n = input.split("\n")[0] let req = [] let string = "" for (let i = 0; i < n; i++) { let el = arr.pop() req.push(el) } req.forEach((element) => { string += element + " " }) console.log(string); } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
Editor Settings
Theme
Key bindings
Full width
Lines