Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning
iconfalse

No TeX is allowed in the code portion of a TeX question, especially in the definition of answer units. To avoid errors, spell out units that require more complicated symbols, like degrees, percents, etc.

Javascript (JS)

A Javascript question will be defined like a Javascript function: function js_answer() { }. All code you write in this section must be contained in the function brackets. When using Javascript in the code portion of a TeX question, take special notice of semicolons and matching opening and closing braces {}. Like any Javascript code, each statement must end in a semicolon and all functions, loops, and conditional statement blocks must begin and end in curly braces. If you want to learn a little more about Javascript in general, try this link.

Info
iconfalse

For more details about using Javascript, use question ID 169286 as a template to create a reference question in your bank.

Javascript (JS) is one of the coding languages used in the code box for Tex & (C/JS) or html+JS. If you're unfamiliar with this language here are a few primers:

C

When writing the coding portion of the question in C, begin with "void answer(void) { }" and insert all code between the curly braces. Any variables you want to reference in the TeX portion of the problem must be defined as follows: /* global (insert type) (insert name) */ (without the parentheses). You can also specify units you want to be displayed after the variable by typing "u={type}" where type can be m, kg, etc. The rest of the problem can then be coded like a normal C program.

...