補(bǔ)充測(cè)試+Git演示

更改后的main

/**
 * Created by lenovo on 2017/5/18.
 */
var test=function(){
};

test.prototype.sort=function(words) {
    var res = [];
    var p;
    var s=words;
    var ary = s.split(' ');
    ary.sort();
    if(words == '')
    {
        return "";
    }
    else
    {
    for(var i = 0;i<ary.length;)
    {
        var count = 0;
        for(var j=i;j<ary.length;j++)
        {
            if(ary[i] == ary[j])
            {
                count++;
            }
        }
        res.push([ary[i],count]);
        i+=count;
    }
//res 二維數(shù)維中保存了 值和值的重復(fù)數(shù)
    for(var x=0;x<res.length;x++) {
        for (var i = x; i < res.length; i++) {

            if (res[x][1] < res[i][1]) {
                var max=res[i];
                for (j = x; j < i; i--) {
                    res[i] = res[i - 1];
                }
                res[x] = max;
            }

        }
    }
    for(var i=0;i<res.length;i++)
    {
        console.log(res[i][0]+" "+res[i][1]+"\r\n");
        //document.writeln(res[i][0]+" "+res[i][1]+"<br/>");
    }
    }
}

module.exports = test;

測(cè)試代碼

/**
 * Created by lenovo on 2017/5/18.
 */
var test = require("../lib/main");
describe("FrequencyN", function () {

     it("should return equal", function () {
            var result = new test();
         //noinspection JSUnresolvedFunction
         expect(result.sort("")).toEqual("");
        });
     it("should return one word one number", function () {
            var result = new test();
         //noinspection JSUnresolvedFunction
         expect(result.sort("he")).toEqual("he 1");
        });
     it("should return one word one number", function () {
            var result = new test();
         //noinspection JSUnresolvedFunction
         expect(result.sort("he is")).toEqual("he 1\r\nis 1");
        });
     it("should return one word one number", function () {
            var result = new test();
         //noinspection JSUnresolvedFunction
         expect(result.sort("he is is")).toEqual("is 2\r\nhe 1");
        })
     it("should return one word one number", function () {
            var result = new test();
         //noinspection JSUnresolvedFunction
         expect(result.sort("it was the age of wisdom it was the age of foolishness it is")).toEqual(
             "it 3\r\nwas 2\r\nthe 2\r\nage 2\r\nof 2\r\nwisdom 1\r\nfoolishness 1\r\nis 1");
        });

    });

Git練習(xí)

![7SVLED@8Z}UD]YRVRHB0P(O.png](http://upload-images.jianshu.io/upload_images/5439747-e0b7eda6f4c6911e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![VK]@ZU8ZH03}4N8}]1~JFAH.png](http://upload-images.jianshu.io/upload_images/5439747-589aed8fc04dd1a1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

ZRBV0GY4T3U$Q4{5(RN13YI.png

O7E~09EKR7GX86~~E%C%V}N.png

![LEJ66P6]LB@Y%RZPCTZ5`(Q.png](http://upload-images.jianshu.io/upload_images/5439747-c0d68681ba6882d2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
JG0DJ%WJAL@9V)ZSLV42VR7.png

Git上傳到遠(yuǎn)程倉(cāng)庫(kù)

![)BY]4OB(5BGSYTH8Z1_{1}2.png](http://upload-images.jianshu.io/upload_images/5439747-ae687e82b1a2c0fe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

()GZ~_0%G@}$CKPUND9(TAS.png

{Y24T{BVU[YEH_QDBKC~QMO.png](http://upload-images.jianshu.io/upload_images/5439747-e976a6aee96665a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![]G(BQ{BDZ~8TX%76%R0WX97.png

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,569評(píng)論 19 139
  • 本片內(nèi)容轉(zhuǎn)自CSDN http://blog.csdn.net/ithomer/article/details/7...
    五娃兒閱讀 5,046評(píng)論 2 87
  • 問(wèn)題描述 如何將非字符串常量轉(zhuǎn)為字符串常量?toString和 String.valueOf 貌似都無(wú)法編譯。 在...
    yougang閱讀 11,628評(píng)論 0 5
  • 作者:某人_Valar如需轉(zhuǎn)載請(qǐng)保留原文鏈接EventBus的GitHub地址:https://github.co...
    某人_Valar閱讀 796評(píng)論 0 4
  • 書名:《隱藏的自我-大腦的秘密生活》 | Incognito - The Secret Lives of the ...
    沐熹的星空閱讀 641評(píng)論 0 0

友情鏈接更多精彩內(nèi)容