YNAP Tech
Published in

YNAP Tech

import {wtf } from ‘JavaScript’;

Do they know its quizmas time again

It’s that time of the year again, Christmas party season and I’m starting to write this year’s Pub Quiz.

Last year I included an extremely unpopular round of weird and (maybe) interesting JavaScript quirks. Below are five of the questions, give them a go and see how well you get on.

After there is an answer with a brief for each.

Questions

Entering each of the following into your console would return a value, what is that value.

Question 1

> typeof NaN;

Question 2

> 0.1 + 0.2;

Question 3

> ('b' + 'a' + + 'a' + 'a' + 's' + decodeURI('%21')).toUpperCase();

Question 4

> ('Thats ' + typeof + 'Alexander ' + 'Wang').toUpperCase();

Question 5

> ['👨‍','👨‍', '👧‍', '👦'].reduce((prev, next) => prev+next)

Answers

Question 1

> typeof NaN;
< "number"

Why?: Well JavaScript is actually doing the right thing here, as you probably know NaN stands for Not a Number which is actually a numeric value.

For more information you can read about it .

Question 2

> 0.1 + 0.2;
< 0.30000000000000004

Why?: This is again not a JavaScript issue but one with binary floating point maths standard . 0.1 in the standard binary64 which is what JavaScript uses is represented as:

0.1000000000000000055511151231257827021181583404541015625

Question 3

> ('b' + 'a' + + 'a' + 'a' + 's' + decodeURI('%21')).toUpperCase();
< "BANANAS!"

Why?: + + this evaluates to NaN as you are trying to make an addition with an operator, as Gwen Stefani said this shit is .

Question 4

> ('Thats ' + typeof + 'Alexander ' + 'Wang').toUpperCase();
< "THATS NUMBERWANG"

Why?: typeof + evaluates to number because + is a numerical value but also concatenates the next string and thats .

Edit: I actually got the reasoning behind this wrong, pointed out by , + + 'a' gets parsed as + (+ 'a') and +'a' returns NaN, which is then coerced to string as it’s interpreted as (string) + (the nan) becoming "NaN". Minus one point Robin.

Question 5

> ['👨‍','👨‍', '👧‍', '👦'].reduce((prev, next) => prev + next)
< "👨‍👨‍👧‍👦"

Why?: Emoji are actually part of the unicode standard and include modifiers which allow you to extend and change their structure. Once you know this you can start playing around and having lots of fun.

> '👨‍👨‍👧‍👦'.replace('👦','👧')
< "👨‍👨‍👧‍👧"
> [...'👨‍👨‍👧‍👧']
< ["👨", "‍", "👨", "‍", "👧", "‍", "👧"]

I would like to thank who taught me the .

I think the quiz went down pretty well last year but this round I actually got booed, maybe fair enough but… well that has just given me more fuel for Pub Quizmas 2.

If you are interested in working with me you can reach out to me at .

--

--

Welcome to our dedicated channel for Everything Technology at YOOX NET-A-PORTER GROUP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store