Question of Javascript part II

 1. Identify important features of a code editor.

    a. Save files in .docs or .docx formats

    b. Allows costumization for your personal comfort and ergonomics

    c. Allows editing of graphic file formats such as .jpg, .png, or .psd

    d. Include code completion for the language in which you are working

    e. Includes syntax highlighting.

    f. Opens PDF files.

2. The statement: console.log(6/2); will yield what answer in the console?

    a. 0

    b. 1

    c. 3

3. Identify the syntax errors in this if statement. 

    var name = "John";

    if(name = "John"} console.log("good morning John");

    a. The condition for the if statement is an assignment, not a comparison.

    b. Parentheses should not be used to endclose the condition.

    c. Name is not variable name for a variable because is a keyword

    d. There is an error concering the braces used for enclosing the code block

4. Identify the correct use of the && operator within conditional statement

    a. For a statement to return true all condition separated by the && operator must also evaluated to true

5. What is the role of the loops as a logical flow control structure in Javascript?

    a. Loops are used to repeatedly run a block of code until a contion is met that forces the loop to stop running

6. Which reserved words in Javascript are used with loop control structure?

    a. while

    b. for

7. What is the problem with the loop below? for(var i = 0; i >10; i++){console.log("The value of i is " +i);}

    a. The loops runs forever

    b. The loops has a syntax error

    c. The loops never runs because the initial contion is never met

    d. The console.log statement has a syntax error

8. Suppose you have a program that adds a series of values to provide a sum total, then it checks to see if that sum total is greater than a predefined amount. If it is greater, the program prints each value that made up the sum to the console.log. Which logical flow control structure have been employed in this program?

    a. Sequence

    b. Selection

    c. Loop

9. Whats is the purpose of a named function in Javascript?

    a. To create a generalized reuseable block of code that encapsulates a task.

10. Given this code: function addStuff(item1, item2){var sum = item1+item2; return sum;}

    a. This function has a syntax error

    b. This function returns false

    c. Items 1 is a parameter.

    d. addStuff(); would return a value of 0;

    e. This function returns a value.

    f. addStuff(4,2)would return a value of 6

11. Select all the true statements about function in Javascript?

    a. Function can take other functions passed in as argument.

    b. Function can be named, or be anonymous.

    c. Function can be assigned to variables.

    d. Function cant be passed into other functions.

    e. In Javascript, function are not first class citizens.

    f. There are a few different syntactical options for defining and wriing functions in JavaScript

12. Given this code: 

    function selectColor(color){

        if(color == "red" || color == "blue" | color == "yellow"){

            var colorArray = [];

            for(var i = 0; i < color.length; i++){

                colorArray.push(color[i]);

            }

            return colorArray;

        else{

            return 'the ${color} is not a primary color';

        }

    }

    which statements below are true?

    a. selectColor("red") will return ['r', 'e', 'd']

    b. selectColor("orange")will return "orange is not a primary color"

    c. This function returns false

    d. selectColor("blue") will return['b', 'l', 'u', 'e']

    e. This function returns a value

13. What is the difference between a function and a method in Javascript?

    a. There is essentially no difference

Komentar