Triple line in an alert message

Whing Dela Cruz
Whing Dela Cruz used Ask the Experts™
Hi experts, How to correct codes below? I want to have 3 lines in an alert message. Thank you!

<!Doctype Html>
<button onclick="iGo()">Try</button>

function iGo()
  var m = "Monkey";
  var e = "Eagle";
  alert(m <br/> + "eating" <br/> + e);

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
alert(m + "\neating\n" + e);

Open in new window


It's working thank you, Lee Savidge!
Most Valuable Expert 2017
Distinguished Expert 2018

Referring back to your other question

If the output is going to a destination that renders HTML (and the output is not in <pre></pre> tags) then use <br/> for line breaks.

For text based output (Alert, console, command line etc) use \n


Thank you Julian, I've got it!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial