From 0aff338d29bb28d14a79eb077eb70618fedfdfc2 Mon Sep 17 00:00:00 2001 From: Last-SilverLight-End <68593892+Last-SilverLight-End@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:08:22 +0900 Subject: [PATCH 1/2] feat: reverse_array --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 548d7a0..566ec14 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,15 @@ * @param {number[]} arr */ function reverseArray(arr) { - // 여기에 코드를 작성하세요. + let resultArray = []; + for(let i=0; i< arr.length; i++) { + if(Array.isArray(arr[i])){ + resultArray.push(reverseArray(arr[i])); + } + else{ + resultArray.push(arr[i]); + } + } + return resultArray.reverse(); } - module.exports = reverseArray; From 244eb45888be81a7c110601d3004cb87b260d27d Mon Sep 17 00:00:00 2001 From: Last-SilverLight-End <68593892+Last-SilverLight-End@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:52:35 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20style=20=EC=9D=BC=EB=B6=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 566ec14..d879138 100644 --- a/index.js +++ b/index.js @@ -2,12 +2,11 @@ * @param {number[]} arr */ function reverseArray(arr) { - let resultArray = []; + let resultArray = []; for(let i=0; i< arr.length; i++) { - if(Array.isArray(arr[i])){ + if(Array.isArray(arr[i])) { resultArray.push(reverseArray(arr[i])); - } - else{ + } else { resultArray.push(arr[i]); } }