export function reverseInt(n: number) { return +String(n).replace(/\d/g, (_, i, a) => a.slice(a.length - i - 1, a.length - i)) }
- export function reverseInt(n: number) {
return +String(n).split('').reverse().join('')}- return +String(n).replace(/\d/g, (_, i, a) => a.slice(a.length - i - 1, a.length - i))
- }
// See https://www.chaijs.com for how to use Chai. import { assert } from "chai"; import { reverseInt } from "./solution"; // TODO Add your tests here describe("reverseInt", function() { it("test", function() { assert.strictEqual(reverseInt(1012),2101); assert.strictEqual(reverseInt(103),301); }); });
- // See https://www.chaijs.com for how to use Chai.
- import { assert } from "chai";
- import { reverseInt } from "./solution";
- // TODO Add your tests here
- describe("reverseInt", function() {
- it("test", function() {
- assert.strictEqual(reverseInt(1012),2101);
- assert.strictEqual(reverseInt(103),301);
- });
- });