【发布时间】:2018-04-27 19:22:24
【问题描述】:
这个函数有什么问题?我想给 c_count 加 1 直到达到 100
<script type="text/javascript"> var result = cMat(0); function cMat (c_count) { var limit = 100; match = 1; while (c_count != limit) c_count ++ match; if (c_count == 95) { c_count = 10; } } return (c_count) } </script>
【问题讨论】:
-
那段代码有什么问题?
-
看起来您正试图从
cMat函数外部返回c_count,而不是返回resuilt -
c_count ++ match- 使用c_count++;或++c_count;或c_count += match或 ... 代替。在你的函数定义之后调用result = cMat(0);。在while之后添加{或在末尾删除}
标签: javascript function loops