Test your JavaScript Skills:Fundamentals-17

Photo by Bram Naus on Unsplash

Test your JavaScript Skills:Fundamentals-17

Part 17

Introduction

Namaste, In this blog I will discuss 7 code scenarios on Javascript fundamentals.

  1. Identify the output of the below program

     let a=10;
     const a=11;
     console.log("value", a);
    

    a.10

    b.11

    c.error

    d.undefined

    e.null

    Answer:c

    Reason: There is an error because of re-declaration.

  2. Identify the output of the below program

     function fx() {}
     var fx=10; 
     console.log("value", fx);
    

    a.10

    b.fx(){}

    c.undefined

    d.error

    e.null

    Answer: a

    Reason: There is no re-declaration hence fx takes the last assigned value i.e. 10.

  3. Identify the output of the below program

     let fx4=1;
     function fx4(){} 
     console.log("value", fx4)
    

    a.error

    b.null

    c.undefined

    d.1

    e.fx4(){}

    Answer: a

    Reason: There is an error because of re-declaration

  4. Identify the output of the below program

     var fx5=56;
     function fx5(){
         console.log("fx5");
     }
     console.log(typeof fx5);
    

    a.56

    b.function

    c.number

    d.error

    e.undefined

    Answer: c

    Reason: The typeof of fx5 is a number.

  5. Identify the output of the below program

     function fx() {}
     let fx=30; 
     console.log("value", fx);
    

    a.error

    b.30

    c.fx(){}

    d.undefined

    e.null

    Answer: a

    Reason: There is an error because of re-declaration.

  6. Identify the output of the below program

     var fx5;
     function fx5(){
         console.log("fx5");
     }
     console.log(typeof fx5);
    

    a. function

    b. number

    c. undefined

    d. error

    e. class

    Answer: a

    Reason: The typeof of fx5 is function.

  7. Identify the output of the below program

     function fx3(){}
     const fx3=30; 
     console.log("value", fx3);
    

    a.fx3(){}

    b.30

    c.undefined

    d.error

    e.null

    Answer: d

    Reason: There is an error because of re-declaration.

Did you find this article valuable?

Support Programming with Mahavir by becoming a sponsor. Any amount is appreciated!