-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