I would like to know if my indentation for this file is correct or not because my result that I got is not aline together (not straight).
<html> <head> <title>Javascript for Loop</title> </head> <body> <pre> <script type = "text/javascript" > let x = 5; do { document.write("do while Looping " + x + "\n"); x++; } while (x < 10) </script> </pre> </body> </html>
Result:
You need to remove the text between the <pre>
and the <script>
:
<html> <head> <title>Javascript for Loop</title> </head> <body> <pre><script type = "text/javascript" > let x = 5; do { document.write("do while Looping " + x + "\n"); x++; } while (x < 10) </script> </pre> </body> </html>
Or, even better, avoid document.write
entirely:
let text = ''; let x = 5; do { text += "do while Looping " + x + "\n"; x++; } while (x < 10) document.querySelector('pre').textContent = text;
<pre></pre>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.