简单题 ,但是没做这一题, 没看懂题的意思…
const alphabetBoardPath = function (target) {
let xi, yi, res = '', lx = 0, ly = 0;
for (const c of target) {
xi = (c.charCodeAt() - 97) % 5;
yi = parseInt((c.charCodeAt() - 97) / 5);
res += 'U'.repeat(Math.max(0, ly - yi));
res += 'R'.repeat(Math.max(0, xi - lx));
res += 'L'.repeat(Math.max(0, lx - xi));
res += 'D'.repeat(Math.max(0, yi - ly));
res += '!';
lx = xi;
ly = yi;
}
return res;
};