html - innerHTML and conditional (ternary) operator- "unexpected string" -


can please me? trying enable program load page numbers separated hr tag, except last number (#10). right there appears "unexpected string" in code block after if statement.

i've tried several different permutations line, i'm stumped how working. thank in advance!

var n = 1, str = ""      while (n <= 10) {      if (n % 2 === 0) {        str += "<p class='even'>" + n + (n === 10 ? "" : "<hr>") "</p>"      } else {        str += "<p class='odd'>" + n + "</p><hr>"      }      n++    }      document.queryselector("#target").innerhtml = str
!doctype html>  <html>  <head>  <style>    .even {      color:blue;    }    .odd {      color:red;    }  </style>  </head>  <body>    <div id="target"></div>  </body>  </html>

don't need change:

str += "<p class='even'>" + n + (n === 10 ? "" : "<hr>") "</p>" 

to:

str += "<p class='even'>" + n + (n === 10 ? "" : "<hr>") + "</p>" 

?


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -