Aptitude | JavaScript Course Quiz 3 | Question 4

What will be the output of the following code?

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
if (5) { 
 document.write("I like peanuts"); 
 }
 </script>

chevron_right


(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


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.

About immukul

Executive Software Developer at Cavisson Systems