Tutor Marked Assignment JS TMA-02
In a Nutshell - CIW Course Section 2 Part A
JS TMA-02 - CD Access Code: 7299
Q1. Which of the following statements are correct?
- a) A method that returns a value can be called a function.
- b) Built-in features of JavaScript are not case sensitive.
- c) You cannot create your own JavaScript functions.
- d) Functions can enable code to be written only once to perform a task repeatedly.
Q2. Indicate, using 1, 2, 3 or 4 (1 being the highest, 4 the lowest), the precedence of the following operators:
- a) ()
- b) /
- c) +
- d) --
Q3. The _____ statement repeats a group of statements for a particular range of values.
- a) switch
- b) while
- c) for
- d) if
Q4, Which of the following statements are correct?
- a) The break statement can only be used in a for or a while loop.
- b) The continue statement can only be used in a for or a while loop.
- c) The break statement can be used in all types of loops.
- d) The continue statement can be used in all types of loops.
Q5. Which of the following pieces of coding contain correct syntax?
| a) | function saleItem(){ var item = prompt("Item name?",""); alert("You entered: " + item); } |
| b) | function saleItem()( var item = prompt("Item name?",""); alert("You entered: " + item); ) |
| c) | function saleItem(){ var item = prompt["Item name?",""]; alert["You entered: " + item]; } |
| d) | function saleItem()[ var item = prompt("Item name?",""); alert("You entered: " + item); ] |
Q6. Indicate which of the following statements are correct:
- a) Unary increment and decrement take precedence over multiplication and division.
- b) Multiplication and division take precedence over unary increment and decrement.
- c) Addition and subtraction take precedence over multiplication and division.
- d) Multiplication and division take precedence over addition and subtraction.
Q7. Indicate which of the following statements are correct:
- a) Local variables can only be used by the function in which they are declared.
- b) Global variables are usually declared inside a function and can be accessed from inside or outside any function you define.
- c) Local variables can be used outside or inside any function you define.
- d) Global variables are usually declared outside a function and can be accessed from outside or inside any function you define.
Q8. Which of the following statements are correct:
- a) The parseInt function can return numbers with decimal points.
- b) The parseInt function can return whole numbers.
- c) parseFloat returns numbers with decimal points.
- d) parseFloat returns only whole numbers.
Q9. There are two types of loop control statement, the ________ statement and the ________ statement.
- a) while, for
- b) continue, for
- c) while, break
- d) break, continue
Q10. Which of the following statements are correct:
- a) When using the return statement, the value to be returned is placed after the return keyword.
- b) When using the return statement, the value to be returned is placed before the return keyword.
- c) The value that is returned from a function cannot be assigned to a variable.
- d) The value that is returned from a function can be assigned to a variable.
- e) The value that is returned from a function can be used in an expression.
- f) The value that is returned from a function cannot be used in an expression.

