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

null

undefined

0

name

Answer: undefined

Stomme_poes
—
2012-12-04T13:10:23Z —
#9

ralph said:

<! This is a comment.

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.

masm50
—
2012-12-04T17:53:20Z —
#12

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

xhtmlcoder
—
2012-12-04T19:00:35Z —
#13

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.

AussieJohn
—
2012-12-04T21:12:03Z —
#14

ralph_m said:

Another JS one (might need to be checked/re-phrased by a JS expert, though, like those above):

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

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;

Stomme_poes said:

Re #7: 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.

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

felgall
—
2012-12-04T21:23:49Z —
#15

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.

felgall
—
2012-12-04T21:30:12Z —
#16

AussieJohn said:

This probably depends on how you get the contents of "child"

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.

ralphm
—
2012-12-04T22:58:44Z —
#17

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