Multiple choice

Which of the following is the correct syntax to display “GeeksforGeeks” in alert box using JS?

  1. alertbox(“GeeksforGeeks”);

  2. alert(“GeeksforGeeks”);

  3. msg(“GeeksforGeeks”);

  4. msgbox(“GeeksforGeeks”);

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The standard JavaScript method to display a modal dialog box with a message and an OK button is 'alert()'. Other options like 'alertbox' or 'msgbox' are not valid built-in JavaScript functions.