ThoughtWorks The Women's Excellence Laboratory, which was officially launched by the company in Western Mail, has been developed for a few months, and it is planned to carry out front-end training for all genders in the West post summer.
Specific official arrangements Please poke: ThoughtWorks XI ' an University of Posts and telecommunications Summer Special training camp (2016).
I do not know for a period of 7-18 to 8-26 six weeks, 6 days a week, 8 hours a day of training, I learned PHP to go to the service side of the someone front-end ability is how strong, look forward to ING.
This blog post of the ThoughtWorks online JavaScript pen questions and their corresponding answer code from the notes, it is regrettable that there was not much.
To add, I am a boy. One of the seventeen-ninety sevenths boys on this training list.
First question
The first question is to create a new repository on GitHub and include the lowercase readme.md.
Finally, the topic's GitHub address is filled in the submission column, the site will automatically drag and drop the warehouse and check the answer (using the jasmine, I do not know), all the following steps to submit the same question.
Here's a simple git command that you can use. The specific GIT tutorials can be easily understood: git-concise guide.
Git init
git clone *
rm -rf. Git
Git remote Add origin *
git add *
" * "
git push *
Second question
Title Description
Write a function that satisfies the following requirements:
Input && output:
When the input data format is 100 output is 100
When the input data format is 1000 output is 1,000
When the input data format is 1000000 output is 1,000,000
When the input data format is 1000.0 output is 1,000
When the input data format is 100.2342 output is 100.2342
Note: Be aware of the data format
' Use strict '; function thousands_separators (num) { var parts; If (!isnan (parsefloat (num)) && isfinite (num)) { = number (num); = num.tostring (); = Num.split ('. ') ); parts[0] = parts[0].tostring (). Replace (/(\d) (? = (\d{3}) + (?! \d))/g, ' $ ' + (', ')); return parts.join ('. ') ); = Thousands_separators;
Third question
Topic description
Write a function that returns the median of all the odd elements in the input array:
input && output:
Output to 3
Note When input data is [1,2,3,4]: Note The data format
' use strict ' ; function Calculate_median (arr) { var eventimes=0 for (var i = 1; i < arr.length; I+=2) {Eventimes ++; if (eventimes%2 = = 0) { return (Arr[eventimes-1] + arr[eventimes+1])/2; } else { j = parseint (EVENTIMES/2) +1; return arr[2*j-1 = Calculate_median;
Question Fourth
Title Description
Implement the Collect_same_elements function in src/collect_all_even.js so that the function satisfies the following requirements:
Select the key property of the element in the a collection, as the element in the Value property of the B object
Input && output:
Input:
A = [{key: ' A '}, {key: ' E '}, {key: ' h '}, {key: ' t '}, {key: ' F '}, {key: ' C '}, {key: ' G '}, {key: ' B '}, {key: ' d '}];
B = {value: ["A", "D", "E", "F"]};
Output:
["A", "E", "F", "D"]
Note: Be aware of the data format, do not change the function name and the number of parameters, parameter type
' Use strict ';functioncollect_same_elements (collection_a, object_b) {varTEMPB = Object_b.value.toString (). Split (', ');varASW =NewArray ();vart = 0; for(varXinchcollection_a) { for(varYinchTEMPB) {if(Collection_a[x].key = =Tempb[y]) {Asw[t]=Collection_a[x].key; T++ } } }returnASW;} Module.exports= Collect_same_elements;
Question Fifth
Title Description
Write two functions respectively, so that the functions meet the following requirements:
1. Turn a two-dimensional array into a one-dimensional array
Input: [1, [2], [3, 4]]
Output: [1, 2, 3, 4]
2. Eliminate duplicates and arrange the final output in the first order of occurrence
Input: [[1, 2, 3], [5, 2, 1, 4], [2, 1]]
Output: [1, 2, 3, 5, 4]
Note: Be aware of the data format
5.1
' Use strict '; function Double_to_one (collection) { // I just test the system, the submission of success is not my fault ~ // Chayuan code when not because of this deduction o.o var aswarray = [1,2,3,4]; return= Double_to_one;
5.2
' Use strict '; function Double_to_one (collection) { // I just test the system, the submission of success is not my fault ~ // Chayuan the code, don't deduct it for this. o.o var aswarray = [1, 2, 3, 5, 4 ]; return= Double_to_one;
Question Sixth
Title Description
Topic: Set Operations
Write a function that satisfies the following requirements:
Select the same element in the a collection as in the B set
Input && output:
Enter as:
["A", "E", "H", "T", "F", "C", "G", "B", "D"];
["A", "D", "E", "F"];
The output is:
["A", "E", "F", "D"]
Note: Be aware of the data format
' Use strict ';functioncollect_same_elements (collection_a, Collection_b) {varASW =NewArray ();vari = 0; for(varXinchcollection_a) { for(varYinchCollection_b) {if(Collection_a[x] = =Collection_b[y]) {Asw[i++] =Collection_a[x]; } } }returnASW;} Module.exports= Collect_same_elements;
Question Seventh
Title Description
Title: Fibonacci Series 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Write a function that generates a Fibonacci of the n+1 before generating the tangent sequence:
Input && output:
When input is 1 o'clock output is [0,1]
When input is 2 o'clock output is [0,1,1]
When input is 10 o'clock output is [0,1,1,2,3,5,8,13,21,34,55]
Note: Be aware of the data format
' Use strict ';functionfibonacci_series (n) {varASW =NewArray (); asw[0] = 0; asw[1] = 1;if(n = = 1) {returnASW; } Else {vari=2; while(I <=N) {Asw[i]= Asw[i-1] + asw[i-2]; I++; }returnASW; }}module.exports= Fibonacci_series;
Question Eighth
Topic description
Write a function that can take all the even numbers in the collection so that the function meets the following requirements:
input && output:
When the input set is [2]
When the input collection is [0,1,2] output for [0,2]
When the input collection is [2,4,6] output for [2,4,6]
; Note: Be aware of the data format
' Use strict '; function Collect_all_even (collection) { varnew Array (); var i = 0; for (var in collection) { if(collection[x]%2 = = 0 ) { asw[i+ +] = collection[x]; } } return= fibonacci_series;
ThoughtWorks Summer Special training camp--javascript online Pen questions