Happy Coding Year!

01 Jan 2018

I wish you all a beautiful year, may we all find a good job.

First, a syntactic tip I saw on codewars’ best solutions.

Instruction: Return ‘Even’ if input is even, return ‘Odd’ if it’s odd.

So you would usually do something like that:

function even_or_odd(number) {
  if (number % 2 === 0){
  //then you know it's even
  return 'Even';
  }else{
  return 'Odd'}
}

Well, you can make it much shorter using ternary conditional:

function even_or_odd(number) {
return number % 2 ? 'Odd' : 'Even'
}

It works, because non-zero values are TRUE. (Sorry Zero.)

To write it ternary-style,

More on ternary here

============================

Back to the mobile end course, I’m seeing the end of it…I’ve learned to delete an array of photo url from the cache, which involves making the Service worker, the IndexDB and the browser db communicate together.

Last exercise tomorrow!

I’ll redo all the exercises while taking better notes, because pfiou! that was hard.