Three simple h5/egret/javascript face test __java

Source: Internet
Author: User

The following uses Egret code (TYPESCRIPT)

1

/**
		 * k output value of
		 * *
        /Private Question1 (): void { 
            var i,j,k:number;
            for (i = 0,j = 0;i < 10,j < 6;i++, j + +) {
                k = i + j;
            }
            Console.log ("k=" + K);
        }


2

/**
         * Randomly select 10 digits between 10--100, deposit an array, and sort
         *
        /Private Question2 (): void { 
            var t_arr_source:array< number> = [];
            for (var i:number = 10;i <= 100;i++) { 
                t_arr_source.push (i);
            }
            var length:number = ten;
            var t_arr:array<number> = [];
            for (var j:number = 0;j < length;j++) { 
                var index:number = Math.floor (T_arr_source.length * math.random ());
                T_arr = T_arr.concat (T_arr_source.splice (index,1));
            }
            T_arr.sort ((A:number,b:number) => {return (a > B 1:-1)});
            Console.log ("t_arr=" + t_arr.tostring ());
        }


3

/**
         * array has [1,2,3,3,4,4,5,5,6,1,9,3,25,4] data, output only the number of duplicates
         *
        /Private Question3 (): void { 
            var t_arr_ source:array<number> = [1,2,3,3,4,4,5,5,6,1,9,3,25,4];
            var t_obj:any = {};
            for (var i:number = 0;i < t_arr_source.length;i++) { 
                if (T_obj[t_arr_source[i]]) {
                    T_obj[t_arr_source[i]] + +;
                } else { 
                    t_obj[t_arr_source[i]] = 1;
                }
            } For (var p in t_obj) { 
                if (t_obj[p] = = 1) { 
                    console.log (p)
                ;
            }
        }}




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.