Skip to main content
4 of 4
Updated submission
Eliseo D'Annunzio
  • 7.5k
  • 1
  • 36
  • 73

JavaScript ES6 ES5, 23 17 12

12 bytes

`${!3}`[3-2]

17 bytes: (typeof!3)[2- -3]

23 bytes: _=()=>(typeof!3)[2- -3]

Edit 05/10/2016: Took advantage of templating strings, as well as boolean coercion and string/array indexing... Also realized my previous code used +, I could always salvage 2+3 as 2- -3 at a cost of 2 bytes for each previous example... (Updated code and scores for previous submissions)

Edit 30/08/2016:

I took a different approach, exploiting the fat arrow functions as well as the typeof return type, which is a string. So converting a number to a boolean was easier then, had to encase it in parentheses before pulling the 5th element of the resulting string...

Seems that there was no mention of my answer requiring to be in the form of a function, so I've just stripped the fat arrow function declaration.

Eliseo D'Annunzio
  • 7.5k
  • 1
  • 36
  • 73