Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Jackie Jen
2,723 PointsPlease help. What does if (--) mean in javascript
What does if (--) mean in javascript? i have no idea how to search from google. Below is the javascript code. I was stuck at if (--c). Hope you can clear my problem.
var mspf = 60; // MS per frame
var trailLen = 15; // Characterss per 'strand'
var spawnTime = 20;
var theLetters = "404 page";
var fadeTime = mspf * trailLen * 2; // time until trail.remove()
function rain(){
var randId = Math.floor(Math.random()*1000);
myFun(trailLen,randId);
setInterval(function(){
$("div[id="+randId+"]").remove();
},fadeTime);
}
function myFun (c,uid) {
var id = "";
setTimeout(function(){
if (c == trailLen){
var y = Math.floor(Math.random() * ($("#out").height() / 10) ) * 12; // height / 10 * 12 ensures a small space between trails, and also prevents overlapping (in theory)
var x = Math.floor(Math.random() * ($("#out").width() / 10) ) * 12;
var scale = (Math.random() * 12) + 8;
$("#out").append("<div style='font-size:"+scale+"px;top:"+y+"px;left:"+x+"px;' class='trail' id='"+uid+"'></div>"); // add .trail
}
if (--c){myFun(c,uid);}
$("div[id="+uid+"]").append("<span>"+theLetters.substr(Math.floor(Math.random()*theLetters.length),1)+"</span><br>"); // adds spans to .trail
}, mspf);
}
setInterval(rain,spawnTime);
}
2 Answers

Paolo Villanueva
7,654 Points--c is pre-decrement. You use pre-decrement if you want to change the value first before evaluating the expression. Post-decrement evaluates the expression first before changing the value.
example: var a = 10; var x = --a; //results: both a and x are 9
var a = 10; var x = a--; //results: a = 9 and x = 10
Search pre-increment vs post-increment if you want to go learn more.

jason chan
31,009 Pointsit's shorthand to write minus one.
Jackie Jen
2,723 PointsJackie Jen
2,723 Pointsoh....i forgot -- is decreasing. Thanks alot