【发布时间】:2021-07-25 18:04:57
【问题描述】:
我正在尝试在学习环境中运行此函数,但它会导致“您的程序的输出比预期的长”的错误,因为默认情况下,console.log 会生成一个换行符。有什么办法可以解决这个问题吗?
function calcSquare() {
x = document.getElementsByTagName('input')[0].value;
result = x**2
console.log("The square of", parseInt(x), "is", parseInt(result))
}
【问题讨论】:
-
这个具体是什么环境?
console.log的作用以及打印方式各不相同。 -
@Bergi 是 Viope
-
嗯,我找不到任何关于它们如何执行代码的文档。我建议问问你的老师,或者 Viope 的支持。
标签: javascript function console output newline