One of our recent Triple Time creations is a fun little project called Quizpoint - a quiz site for web geeks.
In order to keep the site entertaining and challenging, we need as many questions as we can source, which is where you guys come in.
We’re looking for JavaScript, Ruby and WordPress questions of all difficulty levels. If you can think of any, post them in this thread, along with the answer and we’ll put them up on the site.
While you’re at it, check Quizpoint out and see just how smart you are!
Another JS one (might need to be checked/re-phrased by a JS expert, though, like those above):
Given an element assigned to a variable “child”, which of the following could be used as part of a script to remove the padding on the child’s parent element?
child[i].parentNode.style.padding = “0”;
child.parentNode.style.padding = “0”;
child[i].parentNode.padding = “0”;
child.parentNode.style.padding = none;
Answer: child[i].parentNode.style.padding = “0”;
(Comment: You can’t use child.parentNode since the child element will be a NodeList, not a single Node—even if there is only one such child element in the document.)
Huh, learned something new. I wondered where MS got that syntax from for their CC’s.
Re #7:
var test = hello.indexOf(“there”);
This is one of those questions where you’d have to be aware of the people you’re sending it to. IndexOf isn’t built into IE and developers who build for the practical web either don’t use it, have built their own (or used Mozilla’s), or would wonder if the expected answer assumes all relevant interpreters can read that and the issue is the capitalisation.
These are some good Javascript questions, but I dunno where you’ll get the Ruby ones.
Found a question with an incorrect answer. It was about the nth-child selector, with 3n+1. It claimed the answer was ‘The first row, then every fourth row’ which is wrong. ‘Every third row’ is the most accurate there, but it said that was incorrect.
The site doesn’t function without JavaScript. You just see a nice “loading…” text and even the site feedback won’t work without JavaScript so I’ll give the feedback here instead.
This probably depends on how you get the contents of “child” - if we take the question literally then child.parentNode would be acceptable to access it because “child” is an element. For example document.getElementById() and document.querySelector() return references to an element rather than a node list. An example snippet might be helpful to qualify the question:
var child = document.getElementById("content").children;
It’s only .indexOf() on Arrays that isn’t present in < IE9. (.indexOf() on strings has been part of the language spec for a lot longer and should be present in older Internet Explorers :))
Regarding the type= question for JavaScript perhaps a better one would be to ask what the standard specifies is the correct type to use when you do specify it.
The answer is of course type=“application/javascript” since text/javascript was deprecated many years ago and only needs to be used in pages where you want to allow the code to be run as jScript where the browser doesn’t support JavaScript - for example in IE8.
I suspect someone is getting var child; and document.getElementById(‘something’).child mixed up - the latter is a nodelist but the first is just a variable that can have any value assigned to it. One example of where using variable names that match the names of DOM elewments can make things confusing.
[ot]Thanks, guys. My questions are just based on my noobie explorations into JS, so if they are wrong or faulty, please just rewrite them properly (and I’ll remove mine) or suggest that they be deleted if they are not worth saving. You are the guys who should be writing these.
Maybe @Pullo and @markbrown4 can come up with some Ruby questions.[/ot]
Hi masm50,
All questions are welcome, trying to make as much of a fun learning experience as possible
No, quizpoint isn’t based on any CMS’s its completely built in house, using backbone.js