我想打印从1到100 并且把能处以7的整数替换成haha 我这么写为什么不对?应该怎么写?
<html>
<head>
<title>无
</title>
<type style>
</style>
<script type="text/javascript">
for (var i=0; i<=100; i++)
{
x=i+1;
if(x%7){
document.write(haha)}
else{
document.write(x)};
}
</script>
</head>
<body>
</body>
</html>
你的代码的问题是:
1,字符串写到页面要加上引号。
document.write("haha")
2,判断的时候if(x%7==0)加上==0