0

This code is not being rendered in multiple lines even though I have used JavaScript template literals. Why is it so?

document.write(`Today is: ${day} 
             The time now is: ${hours} : ${minutes} hrs 
             The year is: ${year}`);
kevinSpaceyIsKeyserSöze
  • 3,693
  • 2
  • 16
  • 25
Ian
  • 1
  • 1
  • 2
    The document is interpreted as HTML. Newlines in HTML are functionally equivalent to spaces. – Pointy Sep 23 '21 at 13:28

2 Answers2

-1

you are missing a new line character. or a <br> The break is for html line breaks. add one or two to get what you want.

  • Thanks for the feedback. the line break
    worked but the new line character \n didn't work. Is there an explanation behind it?
    – Ian Sep 23 '21 at 13:33
-1

use newline character which is \n or <br/> tag