JS implements string processing, as follows: The letter becomes the adjacent letter, the punctuation is unchanged, the result if the vowel letter is uppercase, Z becomes a.

Source: Internet
Author: User

<script type= "Text/javascript" >

function Letterchanges (str) {
Str=str.split ("");//Convert a string into an array
for (i=0;i<str.length;i++) {
Str[i]=str[i].charcodeat ();//convert the characters in the array into ASCLL yards
if (str[i]>64&&str[i]<122) {//By ASCLL code to determine the type of character, with branch structure to classify its processing
if (str[i]==100| | str[i]==104| | str[i]==110| | str[i]==116) {//This is a vowel letter and needs to be capitalized
Str[i]=string.fromcharcode (STR[I]-31);
}
else if (str[i]>96| | STR[I]&LT;90) {//These are not vowels, nor punctuation, add their ascll to 1
Str[i]=string.fromcharcode (str[i]+1);
}
else if (str[i]==90) {//z becomes a
Str[i]= "A";
}
else{
Str[i]=string.fromcharcode (Str[i]);//These are punctuation marks, no change.
}
}
else{
if (str[i]==122) {//z becomes a
Str[i]= "a"
}
else{
Str[i]=string.fromcharcode (Str[i]);//These are all punctuation, maybe punctuation is not appropriate, anyway they are not letters
}
}
}
Str=str.join ("");//change the processed array back to string
return str;
}
var ceshi=letterchanges ("zz{aa[\" ment goes Here ");//Take Boundary value test
document.write (Ceshi);
</script>

JS implements string processing, as follows: The letter becomes the adjacent letter, the punctuation is unchanged, the result if the vowel letter is uppercase, Z becomes a.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.