📜  替换为字母位置 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:42.155000             🧑  作者: Mango

代码示例1
function alphabetPosition(text) {
  var result = "";
  for (var i = 0; i < text.length; i++) {
    var code = text.toUpperCase().charCodeAt(i)
    if (code > 64 && code < 91) result += (code - 64) + " ";
  }

  return result.slice(0, result.length - 1);
}
console.log(alphabetPosition("The sunset sets at twelve o' clock."));