From 234da20f6bc98a7d6304192e0de77bcf0792ed8c Mon Sep 17 00:00:00 2001 From: Salavat Date: Fri, 18 Feb 2022 10:36:18 +0500 Subject: [PATCH] feat:Submitting a Solution --- src/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 83dabdd87..1bee3ff2b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,11 @@ module.exports = function reverse (n) { - + let numAbs = Math.abs(n); + + if (numAbs.toString().length === 2) { + let arr = [...numAbs.toString()].reverse(); + arr.push('0'); + return Number(arr.join('')); + } else { + return Number([...numAbs.toString()].reverse().join('')); + } }