Home / CSE / Javascript - CS :: Classes and Modules

CSE :: Javascript - CS

  1. Consider the following code snippet

    function oddsums(n)

    {

    let total = 0, result=[];

    for(let x = 1; x <= n; x++)

    {

    let odd = 2*x-1;

    total += odd;

    result.push(total);

    }

    return result;

    }


    What would be the output if

    oddsums(5);

    is executed afted the above code snippet ?

  2. A.

     Returns [1,4,9,16,25]

    B.

     Returns [1,2,3,4,5]

    C.

     Returns [3,6,9,12,15]

    D.

     Returns [1,3,5,7,9]

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Consider the following code snippet

    console.log(p)

    If p is not defined, what would be the result or type of error?

  4. A.

     Zero

    B.

     Null

    C.

     ReferenceError

    D.

     ValueNotFoundError

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Consider the following code snippet

    let x=x+1;

    console.log(x);

    What will be the result for the above code snippet?

  6. A.

     0

    B.

     Null

    C.

     ReferenceError

    D.

     NaN

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Consider the following code snippet

    [x,y]=[y,x];

    What is the result of the above code snippet?

  8. A.

     Throws exception

    B.

     Swap the value of the two variables

    C.

     Flashes an error

    D.

     Creates a new reference object

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which looping statement allows XML tags to appear in JavaScript programs and adds API for operating on XML data?

  10. A.

     for loop

    B.

     while loop

    C.

     for/each loop

    D.

     all of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections ?

  12. A.

     ExitIteration

    B.

     AbortIteration

    C.

     Abort

    D.

     StopIteration

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which method of the iterable object returns an iterator object for the collection?

  14. A.

     iterator()

    B.

     _iterator_()

    C.

     _iteration_()

    D.

     _return_iterator_()

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Consider the following code snippet

    let succ = function(x) x+1, yes = function() true, no = function() false;

    What convenience does the above code snippet provide?

  16. A.

     Functional behaviour

    B.

     Modular behaviour

    C.

     No convenience

    D.

     Shorthand expression

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Consider the following code snippet

    data.sort(function(a,b),b-a);

    What does the above code do?

  18. A.

     Sort in the alphabetical order

    B.

     Sort in the chronological order

    C.

     Sort in reverse alphabetical order

    D.

     Sort in reverse numerical order

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the code to be used to trim whitespaces ?

  20. A.

     let trimmed = (l.trim() for (l in lines));

    B.

     let trimmed = (trim(l));

    C.

     let trimmed = l.trim();

    D.

     let trimmed = for(l in lines));

    View Answer

    Workspace

    Discuss Discuss in Forum