Live data from Hacker News

You Can't JavaScript Under Pressure

toys.usvsth3m.com

91–100 of 110 posts

Re: You Can't JavaScript Under Pressure

#94

Could there be a histogram at the end that shows distribution of finishing times? Or at least a leaderboard... I did pretty well [obviously ;)] but I'd like to see where my time falls in relationship to others. I've confirmed that I can, in fact, code under pressure, but to what degree? Other than that, fantastically fun game. My only regret is that it's a one-time game by nature, since obviously the second time arou…

A lot of people posted their results to twitter, you can get an idea of where you fall in avg by giving this a glance over:

https://twitter.com/search?q=I%20completed%20%22You%20Can't%...

Re: You Can't JavaScript Under Pressure

#95
post #16

Fun little puzzles. First 4 went pretty quickly (~8:00) and then the last one took ~7 minutes Googling around for this so I could test if a variable was an integer... n===+n && n===(n|0) Wish I could see my answers after the fact though! Edit: Read the initial requirements of the puzzle, it says sum all the integers , not all the numbers . People using (typeof i[x] == 'number') just got lucky because the test-cases d…

if(typeof i[p] === typeof 3){//it's an int sum += i[p]; }else if(typeof i[p] === typeof [3]){//it's an array recursion(i[p]); } pretty simple no?

no, in this case the first will match on all numbers and the second will match on all objects.

You should learn a little more about JS before you call this simple.

Re: You Can't JavaScript Under Pressure

#96
post #26

Fun distraction. For me it was: 30% figuring out the answer, 20% not having my editor shortcuts available, 50% figuring out how to check if a value is a certain type. Am I the only one that gives their functions preconditions that the input is good? To me, throwing up when you're passed a non-number to a sum method is correct behavior.

TIL there is no typeof === 'array'. -_-

typeof(["an array", "contains multiple things"]) == typeof(["sometimes"])

Re: You Can't JavaScript Under Pressure

#97

Last one reminded me how awful JS is once again. There are 5 different ways to check if an object is an array, some are implementation dependent, and the obvious one doesn't work (typeof x == "array").

typeof(x) === typeof(["something which is certainly", "an array"])

or am i missing something?

Re: You Can't JavaScript Under Pressure

#98

Earlier quoted context omitted.

TIL there is no typeof === 'array'. -_-

typeof(["an array", "contains multiple things"]) == typeof(["sometimes"])

Yes, but:

    typeof(["an array", "contains multiple things"]) == typeof({but_this_one: "is an object"})

Re: You Can't JavaScript Under Pressure

#100

Last one reminded me how awful JS is once again. There are 5 different ways to check if an object is an array, some are implementation dependent, and the obvious one doesn't work (typeof x == "array").

typeof(x) === typeof(["something which is certainly", "an array"]) or am i missing something?

     > typeof ["a", "b"]

    "object"
Of course, since you're told you'll only get numbers, arrays, and strings, that is enough to solve the problem narrowly.
Post reply on HN