JSFiddle - React, Tailwind, and code Playground

by Artem

JavaScript

'use strict';

function trickyDoubles(n) {
  let tmp = n.toString();
  if (tmp.length === 1) return n * 2;
  if (tmp.slice(0, tmp.length / 2) === tmp.slice(-tmp.length / 2)) return n;
  return n * 2;
}

console.log(trickyDoubles(3838));