Zero, cold
During this time, I ran some tests in a short time and had a rare opportunity to sort them out. I would like to share with you the pen questions on the 23rd. Let's not talk about it.
Where to answer a total of seven questions, the first three are mandatory questions, the next two are mandatory questions at the front end, and the last two are mandatory questions for testing, other candidates answer, that is to say, in my front-end position, five answers are required and two answers are selected. Time is 100 minutes.
I. Question
1. The question is written in English. I will translate it to you in poor English. Maybe all the questions are wrong. Sorry, haha. Generally, a function is designed to return a string of no less than the minimum length. If the length of the string is not enough, the input character is used to complete the string. Padstart (string, minlength, padchar) string: needs to appear at the end of the returned result minlength: required value, can be zero or negative, then return the complete string padchar: return: returns the concatenated string, for example, padstart ("7", 3, "0 ") returns "007" padstart ("2010", 3, "0") retruns "2010" as long as it is a basic English translation, the knowledge point test site is okay, if you need an English source question, leave a message below and I will post it. See the following code:
function padStart(string, minLength, padChar) { var strLen = string.length, result = ""; if (strLen <= 0 || strLen == minLength || strLen > minLength) { result = string; } else if (strLen < minLength) { var offset = minLength - strLen; for (var i = 0, len = offset; i < len; i++) { if (i == 0) { result = padChar + string; } else { result = padChar + result; } } } return result;}console.log(padStart("2010", 3, "0")); //2010console.log(padStart("7", 4, "0")); //007 2. compile a simple command line parameter parsing function. The command line parameter name is composed of "-" And English or numbers, for example, "-name", followed by specific values, command line parameters are separated by one or more consecutive spaces. The content in double quotation marks is regarded as a whole and is not parsed. The returned results are separated by parameters and values. It is assumed that the command line content only contains English letters, numbers, spaces, double quotation marks, and minus signs. For example, if the parameter is-name Lily-age 21-school "" University of Oxford ", the returned result is: [-name Lily,-age 21, -School "University of Oxford:
function getParam(str) { var newStr = str.split("-"); console.log(newStr); for (var i = 0, len = newStr.length; i < len; i++) { newStr[i] = "-" + newStr[i] } newStr.shift(); return newStr;}var result = getParam("-name Lily -age 21 -school ‘University of Oxford‘");console.log(result);3. compile a diff function to compare the differences between two strings. If the character exists in the first string and does not exist in the second string, the minus sign and the corresponding string are output; if the character exists in the second string and does not exist in the first string, the plus sign and the corresponding string are output. If the same sub-string exists, NO content in the sub-string needs to be output, the comparison results of the characters are separated by commas (,), and each different string must be found. Make full use of the same substring and optimize the algorithm as much as possible to ensure that the output result is the shortest. The string used as the parameter only contains English letters. Assume that the function prototype is string diff (string a, string B), for example, a = "ABC", B = "aabcbc", the output is "+ A, + B, + C "; A =" ABCDE ", B =" bcdef ", the output is"-, + F "I think this question is not enough to make full use of the same sub-string and optimize the algorithm to ensure that the output result is the shortest possible, or to meet the requirements of the question, I hope you can give some comments and paste your code directly to my blog. Thank you very much. See the following code:
Function diff (stra, strb) {var ARRA = stra. split (""), arrb = strb. split (""), tempstr = "", strina = "", strinb = "", result = ""; for (VAR I = 0, Lena = ARRA. length; I <Lena; I ++) {If (strb. indexof (ARRA [I]) =-1) {// A has B without strina = strina + "-" + ARRA [I] + ",";} else {tempstr = tempstr + ARRA [I] ;}for (VAR J = 0, lenb = arrb. length; j <lenb; j ++) {If (tempstr. indexof (arrb [J]) =-1) {strinb = strinb + "+" + arrb [J] + "," ;}} result = strina + strinb; result = result. slice (0,-1); return result;} console. log (diff ("abce", "ABCD"); //-E, + d4.css topic div is Px in width, the border is 1px, and div1 and div2 are sibling elements. The performance of the two in the following three situations must be drawn respectively.
a) .div1{position:absolute;float:left} .div2{position:absolute;float:right}
b) .div1{postition:relative;float:left} .div2{position:relative;float:right}
c) .div1{position:absolute;float:right} .div2{position:relative;float:left}At that time, I didn't know why, but I was totally confused. In fact, it was very simple. I checked absolute positioning and relative positioning. It was truly out of the normal stream, that is, whether it occupies a position on the page. : 5. Implement the indexof function in JavaScript to determine whether one I string a contains another string B. A) If yes, return the position B that matches string B. If not, return-1 For example, indexof ("hello", "El") returns 1. See the following code:
function indexOf(strA, strB) { var lenA = strA.length, lenB = strB.length; if (lenA < lenB) { return -1; } else if (lenA == lenB) { return 0; } else { for (var j = 0; j < lenA; j++) { if (strA.charAt(j) == strB[0] && strA.substr(j, lenB) == strB) { return j; } } return -1; }}console.log(indexOf("hello", "el")); //1
Iii. Summary
I am a front-end cainiao with limited capabilities. In fact, the pen questions for where to go are still quite basic, but some of my questions are flawed. List the questions for your reference. In addition, the answer to the question may not be correct. Please leave a comment. There must be a lot of code to be optimized. I hope you can give your comments and make common progress. I wish you all the best job.
Where can I go to July 2015 school recruitment test?