The programming question is simple. The whole paper structure is:
First, question and answer question:
What are the framework libraries for understanding the front end?
Second, on-line programming Questions: Identity card grouping
The first way: Identity card grouping
Three, on-line programming Questions: Identity card grouping, statistical characters, hotel prices (three selected two)
The following is the No. 234 question in the third choice two answer.
I also do not understand why there are two parts of the programming problem ~ ~ ~ The following detailed talk about programming topics and JS code implementation:
First way: Identity card grouping
Code:
1 varLine ;2 while(line =Read_line ()) {3 while(Line.indexof ("")! =-1){4line = Line.replace ("", "" ");5 }6 if(Line.length <= 6){7 print (line);8 }9 Else if(Line.length > 6 && line.length <= 14){Ten varline1 = line.substring (0,6); One varLine2 = line.substring (6); APrint (line1 + "" +line2); - } - Else if(Line.length > && line.length <= 18){ the varline1 = line.substring (0,6); - varLine2 = line.substring (6,14); - varLine3 = line.substring (14); -Print (line1 + "+ line2 +" "+line3); + } -}Description: All AC.
Second way: File extension
Code:
1 var Line ; 2 while (line = Read_line ()) {3 while (Line.indexof (".")! =-1) {4Line = Line.split (".") ); 5 Print (line[line.length-1]); 6 }7 }
Description: All AC.
Third Way: Statistical characters
Code:
1 functionfind (obj, key) {2 if(!typeofobj = = = ' object ') {3 return false;4 }5 if(Keyinchobj) {6 return true;7 }8 Else {9 return false;Ten } One } A varLine ; - while(line =Read_line ()) { - if(Object.prototype.toString.call (line) = = = ' [Object String] '){ the while(Line.indexof ("")! =-1){ -line = Line.replace ("", "" "); - } - varJSON = {}; + for(vari = 0; i < line.length; i++){ - if(!find (JSON, line[i])) { +Json[line[i]] = 1; A } at Else if(Find (JSON, Line[i])) { -Json[line[i]] = Json[line[i]] + 1; - if(Json[line[i]] = = 3&& ((line[i]<= ' z ' &&line[i]>= ' a ') | | (Line[i] <= ' Z ' &&line[i] >= ' A '))){ - print (line[i]); - Break; - } in Else { - Continue; to } + } - } the } *}Description: All AC. My implementation seems a bit complicated, the following will optimize the code to continue to update, but also hope that you can more guidance, discuss ideas. Fourth Avenue: Hotel Prices
Explanation: Because the back three is the three-choice two, so the last I did not do.
Where to go net 2017 school recruit online written test (front end engineer) programming questions and JavaScript code