JavaScript Course | Practice Quiz-2

Last Updated :
Discuss
Comments

Question 1

Which of the following javascript functions allows you to get user input data?
  • A
    alert
  • B
    prompt
  • C
    confirm
  • D
    None of the above

Question 2

Which logical operator only accepts a single operand?
  • A
    &&(AND)
  • B
    ||(OR)
  • C
    !(NOT)
  • D
    None of the above

Question 3

What will be the result of the following code? Javascript
<script>
  document.write( true && 1 && 3);
</script>
  • A
    0
  • B
    1
  • C
    true
  • D
    3

Question 4

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

Question 5

What will be the output of the following code? Javascript
<script>
 let ans = 0 / 0;
 document.write(ans);
</script>
  • A
    0
  • B
    infinity
  • C
    NaN
  • D
    None of the above

Question 6

What will be the output of the following code? Javascript
<script>
 let i = 30;
  if( i == 10 || i > 20){
    console.log('Hola');
  }else if( i == 5){
    console.log('Breaking up the code');
  }else{
    console.log('Adios');
 }
</script>
  • A
    Hola
  • B
    Breaking up the code
  • C
    Adios
  • D
    None of the above

Question 7

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

Question 8

What will be the output of the following code? Javascript
 <script>
  let age = 20;
  let result = age>18 ? 'Great' : 'Not so great';
  document.write(result);
 </script>
  • A
    Great
  • B
    Not so great
  • C
    true
  • D
    None of the above

Question 9

What will be the output of the following code? Javascript
<script>
  let y = 1;
  y = typeof x; 
  document.write(typeof y);
</script>
  • A
    string
  • B
    null
  • C
    number
  • D
    boolean

Question 10

What will be the output of the following code? Javascript
 <script>
    var x = [typeof x, typeof y][1];
    document.write(typeof typeof x);
 </script>
  • A
    undefined
  • B
    string
  • C
    number
  • D
    boolean

There are 10 questions to complete.

Take a part in the ongoing discussion