-1
好吧,所以我需要輸出打印空心方塊,我現在處於虧損狀態。我不想要這個答案,但我想要一些提示,以幫助我走上正軌。謝謝!如何在JavaScript中製作空心方塊?
"use strict"
if (process.argv.length < 3) {
console.log("Not enough command-line arguments given.");
console.log("Usage: node lab13_4.js num");
process.exit();
}
var width = parseInt(process.argv[2]);
function makeLine(width) {
var L = "";
for(var w = 0; w < width; w += 1) { // repeated width many times
L = L + ".";
}
return L;
}
// print the line some number of times.
function printLines(line, howMany) {
// print the right number of lines
for (var i = 0; i < howMany; i += 1) { // repeated height many times
console.log(line);
}
}
for (var x = 0; x <= width; x += 1) {
var line = makeLine(x);
printLines(line, x);
}
在你的榜樣,'process'是不確定的。你能否確保你提供**所有**相關的代碼[**最小,完整,可驗證的例子**](http://stackoverflow.com/help/mcve)? :) –
@ObsidianAge:在Node中完美定義。 – Ryan
這是如何工作的,我會輸入「node lab13_4.js」到控制檯,除了我會添加一個數字,就像這個「node lab13_4.js 5」,並且數字5將被放入進程。 – Hutch