Jump to content

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


Yvzslm

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...