Why am I getting this error repeatedly?

Assets/scripting_basics2.js(106,21): BCE0067: There is already a local variable with the name ‘doesFightHappen’. error, I’m just learning to use javascript, and just playing around, and this is the script. . .

function Update ()
	
{

var skylerHappy : boolean = true;
var meganHappy = false;
var skylerCigarretes = 4;
var meganShoesOn = true;
var dishesInSink = true;
var poopOnFloor = true;
var doesFightHappen : boolean = false;


	
	if (skylerHappy == true && skylerCigarretes >= 2)
		{
		var doesFightHappen = false;
		print (doesFightHappen);
		}
	else 
		{
		var doesFightHappen = true;
		print (doesFightHappen);
		}
}


K, so it may be sloppy, and I'm sure I messed it up somewhere stupid, but why wouldn't I be able to change that variable like that to true if I was not happy, and did not have smokes left?!?!?  I stared at it for 10 minutes, can't find the error, and the error doesn't bother me so much as needing to know why its wrong so I don't do it when I'm actually coding something serious.

The error means that you’re trying to declare a variable twice. In line 11 of what you posted, var doesFightHappen : boolean = false; you declare it once, then later you do var doesFightHappen = false; or var doesFightHappen = true; again.

Just drop the var in your if/else clause. It should simply be doesFightHappen = false; or doesFightHappen = true;.

And by the way this would have been easy to google up.

I don’t use JavaScript but i think its because in your if statement you use the var doesFightHappen = false instead of just doesFightHappen = false, creating a new instance of the same boolean, i could be wrong but just try removing the var.