小编Rau*_*ela的帖子

<PRE> 标签不起作用?

在这里,我正在做的是通过在“pre”标签之间换行来打印我的 javascript 代码,如下所示:

<pre>
    var sum = function(toSum) {
    var j = 0;
    for(var i=0; i<toSum.length; i++) {
        j = j + toSum[i];   
    }

    console.log("The sum of array is " + j);
};

sum([1,2,3,4]);

var multiply = function(toMultiply) {
    var j = 1;
    for(var i=0; i<toMultiply.length; i++) {
        j = j * toMultiply[i];  
    }

    console.log("The multiplication of array is " + j);
};

multiply([1,2,3,4]);
</pre>
Run Code Online (Sandbox Code Playgroud)

但我实际得到的是:

var sum = function(toSum) {
var j = 0;
for(var i=0; i
Run Code Online (Sandbox Code Playgroud)

为什么呢?我怎样才能让“ pre …

html pre

1
推荐指数
1
解决办法
1549
查看次数

标签 统计

html ×1

pre ×1