JavaScript Course | Practice Quiz-3

Last Updated :
Discuss
Comments

Question 1

What will be the output of the following code? 

JavaScript
<script>
let result = 0;
for (let i = 0; i < 5; i++) {
  result += i;
}
document.write(result);
</script>
  • A

    5

  • B

    0

  • C

    10

  • D

    None of the above

Question 2

True or false: All keys in an object are strings.
  • A
    True
  • B
    False
  • C
    Depends on the Object type
  • D
    None of the above

Question 3

Given a collection of artists and lists of their songs, would you store the artist-song-list pairs in an Object or an Array?
  • A
    Object
  • B
    Array
  • C
    Function
  • D
    None of the above

Question 4

What will be the output of the following code? JavaScript
 <script>
 if (5) { 
  document.write("I like peanuts"); 
  }
  </script>
  • A
    I like peanuts
  • B
    undefined
  • C
    nothing will be printed
  • D
    None of the above

Question 5

What will be the output of the following code? JavaScript
<script>
let bar  = 1;
foo = {};
foo: {
     bar : 2;
     baz : ++bar;
};
document.write(foo.baz + foo.bar + bar);
</script>
  • A
    NaN
  • B
    5
  • C
    4
  • D
    1

Question 6

What will be the output of the following code? 

< script>

document.write( 10 > 9 > 8 === true );

</ script> 

  • A

    true

  • B

    false

  • C

    1

  • D

    0

Question 7

What will be the output of the following code? JavaScript
<script>
  document.write(String('Hello') == 'Hello');
</script>
  • A
    true
  • B
    false
  • C
    1
  • D
    0

Question 8

What will be the output of the following code? JavaScript
<script>
document.write(( true + false ) > 2 + true );
</script>
  • A
    true
  • B
    false
  • C
    1
  • D
    0

Question 9

What will be the output of the following code? JavaScript
<script>
document.write(Number('1') - 1 == 0);
</script>
  • A
    true
  • B
    false
  • C
    1
  • D
    None of the above

Question 10

What will be the output of the following code? JavaScript
<script>
 document.write(NaN == NaN);
</script>
  • A
    true
  • B
    false
  • C
    1
  • D
    0

There are 10 questions to complete.

Take a part in the ongoing discussion