I am wondering how I would take a phrase that is an array in Javascript then make it so it would output letters next to the letter to show where in the alphabet they are such as Computer outputting 3C15o13m21u and so on. The phrase I have is shown in the code below
var firstPhrase = "Computers are the most fun way to use your time";
alert(firstPhrase);
答案 0 :(得分:0)
这应该有效:
var phrase = 'Computers are the most fun way to use your time';
console.log(phrase.replace(/([a-zA-Z)/g, function(c) {
return (c.toUpperCase().charCodeAt(0) - 64) + c;
}));