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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -