https://learn.makerpass.com/groups/ssp7w/courses/reactorcore/ssp-7w?id=module3%2Fhow-to-run-your-interview https://gist.github.com/jendiamond/a4254b4bffb479b27fbe99d0ac96ac86
Read it slowly.
Read it again.
Write a function called “getElementsLessThan100AtProperty”. Given an object and a key, “getElementsLessThan100AtProperty” returns an array containing all the elements of the array located at the given key that are less than 100.
- Input = Object with a key whose value is an Array
- Output = Array containing all the elements less than 100
Include the type of input / output (ie: Array String)
Include an explanation of what it is (ie: Array of matching elements from both Arrays that are over 10)
-
Ask yourself, out loud what you are assuming
-
Ask at least one question about those assumptions
-
Include these assumptions in the tests
- input is an Object
- the value at the given key is an Array
- the Array is not empty
- that key exists in the Object
- How should I handle the 1st word being longer than the 2nd?
- How should I handle the 2nd word being longer than the 1st?
- Do I need to do anything about uppercase/lowercase?
- Can there be spaces inside the string? If so, do I treat them as letters?
- "should return an array containing all the elements less than 100 in the array located at key"
- "should return an empty array if the array has no elements less than 100"
- "should return an empty array if the property is not an array"
- "should return an empty array if the key does not exist"
if (obj instanceof Object && obj[key] instanceof Array && obj[key] != []) {};
// iterate though the array
// find the elements that are less than 10
// push those element to a new array
// output the elements that are less than 10
- Decide on your core data structure or data type
- What are the start and end states of that data?
- How does that data "mutate" from start state to end state?
- Outline your state-changing logic in English pseudo-code
- Re-read it, edit it, make it clear and precise
- Give those stubs clear names
- Each function -- has a clear contract
- Write an assertion
- Assert what behavior should be true about that component
- Fill in the main function body.
- Stub out helper functions if need be.
- Each function should ideally have a single purpose.
It should do only one, small thing.
That one thing is expressed clearly by the function's name.
- Each function -- has a clear contract
- Write an assertion
- Assert what behavior should be true about that component