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 &lt; instead of <. similarly, use &gt; > , &amp; & when displaying in html.

your loop like:

for(var i=0; i&lt;tosum.length; i++) { ... } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -