r/coding • u/awsometak • Aug 09 '17
Test your Javascript skills with our fun Javascript test!
https://www.atlascode.com/blog/test-your-javascript-skills-with-our-fun-javascript-test/1
u/SanityInAnarchy Aug 10 '17
Question 6 will mark you wrong for differences in spacing. This is extra bullshit because it relies on the behavior of console.log(), which is a "living standard" that ultimately gives multiple possible right answers, some implementation-defined, not even all can be represented as strings -- Chrome represents generic objects as an interactive tree structure, for example.
Even if you "cheat", you get it wrong -- if you actually paste this snippet into Chrome, it spits out this exact string:
function (){
return 'A';
}But the test is expecting this one:
function(){return 'A';
}To make this even worse, when it "grades" you, it puts both your answer and the "correct" answer in <p> tags, verbatim -- no <pre>, no hacks with <br> or , it just tells you that you entered function(){ return 'A'; }, and it wanted function(){return 'A'; }.
I can't be too hard on them, though, because there isn't a good way to fix this with the way they want to use console.log(x) as a shorthand for "What is the value of x?" ...so even if they used a JS parser and compared some fully-normalized ASTs, console.log() would still make them not-quite-correct.
8
u/bigjoebegs Aug 09 '17
Three quick things:
The correct answer to #4 is actually "B".
ParseInt isn't really relevant. I never use it and I don't know why knowing parseInt('ABC') would be useful.
I put quotes around my string answers and got one wrong because of it (wrote 'AB' when the answer was AB)
All around, nice work, but this needs touching up.