我正在尝试在每个学生姓名后添加中断,以便它使用 Javascript 将每个姓名写在不同的行上

I'm trying to add breaks after each student name so it writes each name on a different line using Javascript

这是我完成的 javascript 代码。

<!DOCTYPE html>
<html>
<head>
<title></title>
<body>
<script language = "javascript">
var names = new Array(4);
names[0] = prompt("Enter the students name");
names[1] = prompt("Enter the students name");
names[2] = prompt("Enter the students name");
names[3] = prompt("Enter the students name");
names[4] = prompt("Enter the students name");

document.write("Students name:" + names[0] + "Students name:" + names[1] + "Students 
name:" + names[2]
+ "Students name:" + names[3] + "Students name" + names[4]);

names.sort();

document.write("Students name:" + names[0] + "Students name:" + names[1] + "Students 
name:" + names[2]
+ "Students name:" + names[3] + "Students name" + names[4]);

</script>

</body>
</html>

代码输出类似于此的响应(数组来自用户提示): 同学们name:AdamStudentsname:brianStudentsname:calebStudentsname:aaronStudentsname:brittStudentsname:aaronStudentsname:adamStudentsname:brianStudentsname:brittStudentsname:caleb

我正在尝试让代码像这样输出

学生name:Adam

学生name:brian

学生name:caleb

学生name:britt

学生name:aaron

我尝试使用 \n 进行换行,并使用
进行换行,但添加这些会使代码失败。

如果有人能与我分享如何休息,将不胜感激。

尝试使用 <br> 标签,例如:

 document.write("Students name:" + names[0] + "<br> Students name:" + names[1] + "<br> Students 
    name:" + names[2]
    + "<br> Students name:" + names[3] + "<br> Students name" + names[4]);

使用<br>

document.write("Students name:" + names[0] + "<br>Students name:" + names[1] + "<br>Students 
name:" + names[2]
+ "<br>Students name:" + names[3] + "<br>Students name" + names[4]);