We Need Quiz Questions for Our New Site - QuizPoint

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!

This is a fun idea! I’ve already tried a quiz, and it was fun. :slight_smile:

Here’s a simple JS one:

When linking to a script, which of these is the best option for the type attribute?

type=“javascript”

type=“script”

type=“text/javascript”

These days, you don’t need it at all

Answer: These days, you don’t need it at all

Another JS one:

Which of these is NOT a valid comment in JavaScript:

// This is a comment.

/* This is a comment. */

/* This is a comment.

<!-- This is a comment.

Answer:

/* This is a comment

Another JS question:

Which statement best explains what “unobtrusive JavaScript” is?

JavaScript that doesn’t annoy users

JavaScript that is separate from HTML

JavaScript that does not affect a web page

JavaScript that works even with scripting turned off

Answer: JavaScript that is separate from HTML

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.)

Another JS question:

[B]How will the following code be output?

var text = “Statement one
Statement two
Statement three”;
console.log(text);[/B]

Uncaught Syntax Error: Unexpected token ILLEGAL

Statement one
Statement two
Statement three

Statement oneStatement twoStatement three

Statement one Statement two Statement three

Answer: Uncaught Syntax Error: Unexpected token ILLEGAL

Explanation: You cannot create a string that spans multiple lines in JavaScript.

JS question:

[B]How will the following code be output?

var hello = “Hi There!”;
var test = hello.indexOf(“there”);
console.log(test);[/B]

3

Undefined

-1

4

Answer: -1

JS question:

If this code were run, what value would be output for the variable “name”?
var name;

null

undefined

0

name

Answer: undefined

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.

[ot]

Sigh … wouldn’t ya know? :rolleyes: (I’m just learning about it.) [/ot]

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.

Slightly off topic - but what did you use to build Quizpoint? Did you base it on any CMS or build it in house completely?

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. :slight_smile:

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. :slight_smile:

Maybe @Pullo and @markbrown4 can come up with some Ruby questions.[/ot]

Hi Stormrider,
Nice find, seems someones made a typo.

All fixed up!

Thanks for your time :slight_smile:

Hi xhtmlcoder,
Yes at the moment the site will only work with javascript, still in early stages of development :slight_smile:

Thanks for you time :slight_smile:

Hi masm50,
All questions are welcome, trying to make as much of a fun learning experience as possible :slight_smile:
No, quizpoint isn’t based on any CMS’s its completely built in house, using backbone.js

Thanks for your time, and using Quizpoint.com :slight_smile: