html - <PRE> TAG doesn't work? -
here, doing printing javascript code wrapping between "pre" tags :
<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 " + 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 " + j); }; multiply([1,2,3,4]); </pre>
but actual getting :
var sum = function(tosum) { var j = 0; for(var i=0;
why so? how can "pre" tag working?
you should use <
instead of <
. similarly, use >
>
, &
&
when displaying in html.
your loop like:
for(var i=0; i<tosum.length; i++) { ... }
Comments
Post a Comment