JS Programming Little Practice 2の Cattle

Source: Internet
Author: User

1-

function Dnastr (s) {  //ps: No AC, see bug Please indicate    if (s.length>=1&&s.length<=50) {        var rege=/^[a-z] +$/g;        if (Rege.exec (s)) {            var reg=/[atcg]{1,4}/g;            var tmp= s.match (reg);            var lens=[];            var max=0;            for (var key in tmp) {                lens.push (tmp[key].length);            }            for (var key in lens) {                if (Lens[key] > max) {                    max = Lens[key];                }            }            return Max;}}    } var s= "Tarcat" Console.log (DNASTR (s));

2-

function Issame (str) {  //determines if the string    var begin = 0    var end = Str.length/2 while    (End < Str.length && Str[begin] = = Str[end]) {        begin++        end++    }    if (end = = Str.length  ) {        return true    }    return false}function  isostring (str) {  //after removing several characters from the end, determine whether or not a string of    var max = 0    if (str.length <= 1) {        return str.length    }    while (Str.length >=2) {        str = str.slice (0,str.length-2)        if (Issame (str)) {  //calls the even-string judgment method            return Str.length        }    }    return 0}console.log (isostring ("Abaababaab"))

3-

PS: See the bug to help point out, Xie

JS Programming Little Practice 2の Cattle

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.