我只是不明白这个说法 [英] I just dont understand for this statement

查看:76
本文介绍了我只是不明白这个说法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function draw()
			{
				var i=1;
				var j=1;
				var num=prompt("Please enter a number");
				
				for (i=1;i<=10;i++)
				{
					document.write("<tr><td align='center'>");
					for(j=1;j&lt;=i;j++)
					{
						
						
						if(j==num)
						{
							
							document.write("<font color='red'>"+j+"</font>");
							
						}
						else{
							document.write(j);
						}
						
						
						
					}
		This statement>>>                 document.write("</td></tr>");	 			
				}
				
			}







<h1>2^10 is 1024</h1>
		
			
		<table>
				draw();
			</table>















为什么这句话应该在第一轮for循环结束时写出来?



我有什么尝试过:



放在第二个for循环但遇到问题








Why this statement should write at the end of first for loop?

What I have tried:

Put at the second for loop but got problem

推荐答案

你打开第一个循环开始时的 tr td 元素。



因此,你需要在第一个循环结束时关闭它们是完全合乎逻辑的。



HTML元素 [ ^ ]
You open the tr and td elements at the start of the first loop.

Therefore, it's perfectly logical that you would need to close them at the end of the first loop.

HTML Elements[^]




解决方案将是



示例如果拿了num = 4



那么答案将是



num = 4;

i = 1;

j = 1;





for(i = 1; i< = 10; i ++)

for(j = 1; j< = 10 ; j ++)两种情况



打印

(计数i = 1和j = 1)





j (计数i = 1和j = 4)











Hi,
solution will be

example if took num = 4

then answer will be

num = 4;
i=1;
j=1;


for(i=1;i<=10;i++)
for(j=1;j<=10;j++) on two condition

it prints
(count i=1 and j=1)
.
.
j(count i=1 and j=4)
.
.
.
.
.
<font color="red">j</font>(count i=2 and j=4)
.
.
. when j=4 then only u can see the j value..
please give boarder as 1 so that u can see table structure.


这篇关于我只是不明白这个说法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆