const num1 = 7482; // 7482
const num2 = nn(num1); // 2487
function nn(num) {
const str = num.toString();
const mid = str.slice(1,str.length-1);
const one = str[0];
const end = str[str.length-1];
const res = `${end}${mid}${one}`;
return Number(res);
}
const num1 = 7482; // 7482
const num2 = nn(num1); // 2748
function nn(num) {
const str = num.toString();
const mid = str.slice(0,str.length-1);
const end = str[str.length-1];
const res = `${end}${mid}`;
return Number(res);
}