Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Aptitude | JavaScript Course Quiz 3 | Question 4

  • Last Updated : 10 May, 2019

What will be the output of the following code?




<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


Answer: (A)

Explanation: In Javascript, Any natural number other than 0 is taken as true, therefore “I like peanuts” will be printed.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :