javascript - how to output the result to either console or on the page -


ok, embarrased asking such basic question here goes. , yes, googled it, reason light bulb doesn't go off.

so, here's sample code:

var name = "oy vey";  for(var = 0; < name.length; i++) {     return name[i]; }; 

how output in browser's console?

or print out results on web page?

(yes, know, basic question. please kind)

if use return statement in looping first result of iteration remember that. can use console.log() or can use html render result, this:

 <!doctype html>      <html>      <body>        <h2>javascript output</h2>        <p id="demo"></p>        <script>      var name = "oy vey";      var leng_name = "";      var i;      (i = 0; < name.length; i++) {          leng_name += +   "<br>";      }      document.getelementbyid("demo").innerhtml = leng_name;      </script>        </body>      </html>


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -