First of all, make clear our task for this time.
This assignment is divided into four parts.
-
Git Creates Version Library
First
- Using cd to enter version Library
- mkdir creates a version Library
The pwd command is used to display the current directory
As shown in the following figure
- Make this directory a git manageable repository through git init
At this point, there will be an additional. git directory in the current testgit directory (don't change the files in that directory because the directory is used by git to track the management version)
Second
Version regression
Through the above description, the modification of the file has been described, and now continue to modify the readme.txt file, add a line 333333, continue to execute the order as follows:
Now the readme.txt file has been modified three times. To view the history, you can use the command: git log, as shown below:
If you think that Figure 1 shows too much information, you can use the command git log --pretty=oneline, as shown in Figure 1.
If you want to return the current version to the previous version, you can use the following two commands. The first one is git reset - hard HEAD ^. If you want to go back to the previous version, you only need to change HEAD ^ to HEAD ^ and so on.
Let's take a look at readme.txt again. See it through the command cat readme.txt, and you can continue to use git log to view the history information.
Add 333333 content did not see, but now want to return to the latest version,
- First, get the version number through git reset-hard
- Then restore with git reset-hard 6fcfc89
Specifically as follows:
-
Next, let's talk about Git Undo Modification and Delete Files
Git Undo, Modify. png
Now let's talk about Nodejs.
First record my first Hello World program
- For Node js, Node.js is a Web application framework based on Google Chrome's JavaScript engine (V8 engine). Quick Start to Node.js
Node.js = runtime environment + JavaScript Library
-
The difference between Nodejs and JavaScript
- node.js is quite different from javascript. One is platform and the other is programming language.
- javascript is a client programming language, which needs the interpreter of the browser to interpret and execute.
- node.js is a platform based on Chrome JavaScript runtime. It is a running environment that encapsulates the Google V8 engine.
- Simply speaking, node.js is to encapsulate the browser interpreter as a server running platform, programming with a structure grammar similar to javascript, running on node.js.
TDD code
describe("Word Frequency", function () { it("returns empty string given empty string", function () { var result = main(''); expect(result).toEqual(''); }); it("returns string given one word", function () { var result = main('he'); expect(result).toEqual('he 1'); }); it("returns string given two different word", function () { var result = main('he is'); expect(result).toEqual('he 1\r\nis 1'); }); it("returns string given two duplicated word", function () { var result = main('he is he'); expect(result).toEqual('he 2\r\nis 1'); }); it("returns string given two duplicated words need to be sorted", function () { var result = main('he is is'); expect(result).toEqual('is 2\r\nhe 1'); }); it("returns string given two duplicated words splited by multiple spaces", function () { var result = main('he is'); expect(result).toEqual('he 1\r\nis 1'); }); it("returns string given long string splited by multiple spaces", function () { var result = main('it was the age of wisdom it was the age of foolishness it is'); expect(result).toEqual('it 3\r\nwas 2\r\nthe 2\r\nage 2\r\nof 2\r\nwisdom 1\r\nfoolishness 1\r\nis 1'); document.write("result:"+"<br>"+result); });
var formatWordAndCount = function (word, count) { return word + ' ' + count; }; var group = function (wordArray) { return wordArray.reduce((array,word)=>{ let entry = array.find((e)=> e.word === word);//Finding Objects if(entry){ entry.count++; }else{ array.push({word:word , count:1}); } return array; },[]); }; var split = function (words) { return words.split(/\s+/); }; var sort = function (groupWords) { groupWords.sort((x, y) => y.count - x.count); }; function format(groupWords) { return groupWords.map((e) = > formatWordAndCount(e.word, e.count)).join('\r\n'); } function main(words){ if(words !== ''){ let wordArray=split(words); let groupWords = group(wordArray); sort(groupWords); return format(groupWords); } return '' }
Experience of this assignment
- Generally speaking, all kinds of difficulties lie ahead. For me, Git and Nodejs are two new things. I need to learn step by step. It takes a lot of time from installation environment to familiarity with usage. Then I can't write the code at first. There is a kind of "topic knows you, but you don't." After that, I consulted my classmates and slowly explored myself, finally knocked out the code after stumbling. No matter what the process was, it was difficult, but there would be a sense of accomplishment after the real completion.
- Secondly, this task I think also has a lot of promotion to my independent learning, but also found a lot of learning knowledge of the new continent.
Then I recommend a website for technical bulls to publish articles. community
Good App Collection app