Sharing my approaches to solving the checkio typescript problems https://checkio.org/
This is a bit of a learning exercise for me, so I am approaching the problems and solving them in my own way, then checking against solutions. And then making sure I understand the solutions, and trying them out myself.
Don't peek if you don't want to be spoiled.
Things I've learnt/things that would be useful to remember in future:
- logical operators return booleans!
- read documentation fully - make sure you grasp what methods are actually returning.
- https://regex101.com/ is useful!
- There seems to be methods for everything you ever need to do on arrays - see if these help before looping... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
- array.sort is complicated. -1 means moving a forward, and 1 means moving b forward. 0 means no change. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
-
- you can manipulate a and b, you only need to return -1, 0 and 1 within the function, the sort does all the magic on the array itself. Actual magic!
- useful string method https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split