JSFiddle - React, Tailwind, and code Playground
JavaScript
const doubleNum = num => {
const str = num.toString();
const half = str.slice(str.length / 2);
console.error(str.length / 2);
return half + half === str ? num : num * 2;
};
doubleNum('123');
doubleNum('1234');
doubleNum('11111');