Live data from Hacker News

You Can't JavaScript Under Pressure

toys.usvsth3m.com

101–110 of 110 posts

Re: You Can't JavaScript Under Pressure

#101

there's a truly dubious test case in the File Extension test. file called .htaccess is not filename "" and extension "htaccess" with a "." separating the two. .htaccess is a unix style dotfile. its whole name is ".htaccess" and it has no file extension.

I have to admit to cheating and putting 'if (i === '.htaccess') return 'htaccess';' to save time :)

I just did

return i.indexOf('.') > -1 ? i.substring(i.indexOf('.')+1) : false;

Seemed to pass all test cases

Re: You Can't JavaScript Under Pressure

#102

That was fun! I just got in to work so I was properly sleeping. I also rarely use typeof, so I had to look up that 'integer' and 'array' do not exist :) Also, what was really annoying is the use of 'i' for the argument. That's what I exclusively use for the 'for loop' index! Tripped me up a lot, I had to consciously remind myself every time I accessed the array. Last 'also', the font is WAY too big for my small scree…

The use of 'i' set me back a bit, too. Caused me to go into an infinite loop at one point.

Exactly this. I had to rename `i` for indexes to `j` and that really messes my head up! :(

Re: You Can't JavaScript Under Pressure

#103

Earlier quoted context omitted.

I have to admit to cheating and putting 'if (i === '.htaccess') return 'htaccess';' to save time :)

I just did return i.indexOf('.') > -1 ? i.substring(i.indexOf('.')+1) : false; Seemed to pass all test cases

Aye, I did similarly, though for some reason I did >= 0 instead of > -1. I wonder what % of people choose one test approach vs. the other?

Re: You Can't JavaScript Under Pressure

#104
post #8

What's everyone's times? I did 7 minutes

8:11 for me - as it sounds like was the case with others, the majority of that time was searching for how to check for specific types in Javascript.

For the "is this actually a string?" check, for example, I started looking for the existence of the match method on the object, which of course would have failed if they passed some random object with match defined so I cheated a bit. I'd like to see the full breadth of test options people took out there.

Re: You Can't JavaScript Under Pressure

#107

Earlier quoted context omitted.

I just did return i.indexOf('.') > -1 ? i.substring(i.indexOf('.')+1) : false; Seemed to pass all test cases

Aye, I did similarly, though for some reason I did >= 0 instead of > -1. I wonder what % of people choose one test approach vs. the other?

I chose >= 0, it's fun to learn!

Re: You Can't JavaScript Under Pressure

#108
post #90

Earlier quoted context omitted.

Maybe I'm naive but... I suspect that the rest of the page wouldn't have worked with NoScript. Since you're, you know, typing in JavaScript code and running it against some test cases.

I am using Noscript and the page works fine: - usvsthem is white-listed so Javascript runs, which is all that's strictly required. - White-listed sites are still blocked from running plugins including . It's straightforward to override this on a plugin-by-plugin basis but I typically don't want to. 11:14. The 14 seconds were enough for the first two questions, but I find strings and array handling tough when switchin…

Ahhh that's pretty cool!

Re: You Can't JavaScript Under Pressure

#109
post #2

Oh! Hello. This is my thing I made for usvsth3m.com. Hope y'all like it. HTML5 Webworkers made it possible - sandboxing user-submitted JavaScript so an accidental while(1) or document.write can't kill everything. Do have a look at the source code. Oh, and try turning up your speakers and typing in the Konami code...

Oh, you, Tom Scott, made it? :D I'm a big fan.

A few suggestions, then:

1. Don't use i as the name of the parameter. A lot of people use that as the name of loop variables, and it means breaking habit or wasting time changing the name.

2. For test 3, try some multiple-extension files to make sure they did it right (some.file.multiple.extensions, should return "extensions")

3. For test 5, it says "integers". Try some non-integers during testing, to make sure that it's only checking for integers.

4. For test 5, it says "arrays". Try some objects to make sure they're not being lazy and using typeof thing === "object"

Anyway, thanks for making this. I love it!

Re: You Can't JavaScript Under Pressure

#110
post #2

Oh! Hello. This is my thing I made for usvsth3m.com. Hope y'all like it. HTML5 Webworkers made it possible - sandboxing user-submitted JavaScript so an accidental while(1) or document.write can't kill everything. Do have a look at the source code. Oh, and try turning up your speakers and typing in the Konami code...

Oh, you, Tom Scott, made it? :D I'm a big fan.

A few suggestions, then:

1. Don't use i as the name of the parameter. A lot of people use that as the name of loop variables, and it means breaking habit or wasting time changing the name.

2. For test 3, try some multiple-extension files to make sure they did it right (some.file.multiple.extensions, should return "extensions")

3. For test 5, it says "integers". Try some non-integers during testing, to make sure that it's only checking for integers.

4. For test 5, it says "arrays". Try some objects to make sure they're not being lazy and using typeof thing === "object"

Anyway, thanks for making this. I love it!

Post reply on HN