❇ Crisp n Clear👌 🏆O(N)❤️ Javascript❤️ Memory👀77.59%🕕 Meaningful Vars✍️ 🔴❇ ✅ 👉 💪🙏
\n\nvar smallestNumber = function (num) {\n    if (num === 0) {\n        return 0;\n    }\n    const stringNum = num.toString();\n    if (num < 0) {\n        re
![image](https://assets.leetcode.com/users/images/750d4e03-10ff-46ec-b8bb-8c7141cb19d0_1670118551.1778061.png)\n```\nvar smallestNumber = function (num) {\n    if (num === 0) {\n        return 0;\n    }\n    const stringNum = num.toString();\n    if (num < 0) {\n        return (\n            Number(\n                stringNum\n                    .substring(1)\n                    .split(\'\')\n                    .sort((a, b) => Number(b) - Number(a))\n                    .join(\'\')\n            ) * -1\n        );\n    } else {\n        const splittedString = stringNum.split(\'\');\n        const sortedString = splittedString.sort(\n            (a, b) => Number(a) - Number(b)\n        );\n        if (sortedString[0] === \'0\') {\n            const indexOfNonZeroNum = (function () {\n                for (let index = 0; index < splittedString.length; index++) {\n                    if (splittedString[index] !== \'0\') {\n                        return index;\n                    }\n                }\n            })();\n            const store = splittedString[0];\n            splittedString[0] = splittedString[indexOfNonZeroNum];\n            splittedString[indexOfNonZeroNum] = store;\n        }\n        return Number(sortedString.join(\'\'));\n    }\n};\n```
['JavaScript']