Jump to content

Meaning of 'var text = "";' - The For Loop


Recommended Posts

Greetings!

 

I do not understand why I have to describe that variable " ".

http://www.w3schools.com/js/tryit.asp?filename=tryjs_loop_for_ex

 

When I put a letter in it, it returns "aThe number is 0 (...)" only the first character, not every loop.

So why we need to describe empty value. Why we want to write there nothing ->

 

why.png

Link to post
Share on other sites

That line of code creates the variable (reserves space in the computer's memory) and tells it to be a string with no content in it.

 

As dsonsuk said, try removing that line and see what shows up in the browser's Javascript console (most browsers let you access the console by pressing F12)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...