Earlier quoted context omitted.
TIL there is no typeof === 'array'. -_-
[] instanceof Array; // returns true
You Can't JavaScript Under Pressure
91–100 of 110 posts
Re: You Can't JavaScript Under Pressure
#92Re: You Can't JavaScript Under Pressure
#93What's everyone's times? I did 7 minutes
Spent nearly the entire time on #3 because I was trying to use String.replace to work and failing. Ended up using .split instead, which passed thanks to poor test coverage (just like at work!).
Re: You Can't JavaScript Under Pressure
#94Could 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…
https://twitter.com/search?q=I%20completed%20%22You%20Can't%...
Re: You Can't JavaScript Under Pressure
#95Fun 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?
You should learn a little more about JS before you call this simple.
Re: You Can't JavaScript Under Pressure
#96Fun 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'. -_-
Re: You Can't JavaScript Under Pressure
#97Last 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").
or am i missing something?
Re: You Can't JavaScript Under Pressure
#98Re: You Can't JavaScript Under Pressure
#99Last 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").
Re: You Can't JavaScript Under Pressure
#100Last 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.