maryluis 4 年之前
父節點
當前提交
a4ba37f61a
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      homework5js/script.js

+ 2 - 6
homework5js/script.js

@@ -219,12 +219,8 @@ alert (sum)
 function chessOneLine() {
     let num = +prompt("String length is...");
     let string = "";
-    for(;num > 0; num = num - 1){
-        if (num % 2 == 0) {
-            string += "#";
-        } else {
-            string += " ";
-        }
+    for(let i = 0;i < num; i++){
+        string += "#" + " ";
     }
     return console.log(string)
 }