- Each challenge is essentially finding a way to transform the given input to the output desired.
- understand the problem (you want to change the input to the output) nothing more nothing less
- break solution down into steps of pseudocode then ask how for each step
- test each line to make sure they are doing what you expect them to do
-
Pseudoode is the most important part.
-
The more methods you know the better.
-
Test each line as you go along and console log to make sure the code does what you want it to
-
When things don't work as expected look up the documentation
-
Limit time that you are stuck to only 15 minutes
-
It is helpful to look at the solution and reverse engineer it if you aren't able to solve it
-
Once you've looked at the solution try it again to see how much you've learned
-
Each problem can be taken to the next step by trying to understand the Big O of your solutions
Strings
- .split('') * splits strings on whatever is passed into the parenthesis ```javascript const str = 'The quick brown fox jumps over the lazy dog.';
const words = str.split(' ');
console.log(words);
Array ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog."]
```
Arrays
- .sort() * sorts arrays by values inside * numbers need a helper function because they are sorted as strings
```javascript
let fruits = ["Banana", "Orange", "Apple", "Mango"];
// Apple, Banana, Mango, Orange
let points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return a - b});
// 1,5,10,25,40,100
```
Strings
- .split('') * splits strings on whatever is passed into the parenthesis ```python text= 'Love thy neighbor'
# splits at space
print(text.split())
['Love', 'thy', 'neighbor']
```