0

I saw some code online and it had this in it:

document.writeln("<p>");
for (var line = 10; line --> 0;) { // --> operator here
  for (var i = 10; i --> 0;) {     // --> operator here
    var s = (Math.floor((Math.random()*2)%2)) ? "╱" : "╲";
    document.write(s);
  }
  document.writeln("<br>");
}
document.writeln("</p>");
p { 
  line-height: 18px; 
  font-size: 18px; 
}

What exactly is this --> operator and what does it do?

0

2 Answers 2

2

There isn't a --> operator.

That is just a Postfix Decrement Operator immediately followed by a Greater Than Operator.

It would more usually be written as:

for (var i = 10; i-- > 0;) { 
Sign up to request clarification or add additional context in comments.

Comments

0

It is a decrement (--) followed by a comparison (>). These would normally be written with a space to make it easier to read.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.