Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

JavaScript code not working

Please explain whey the following does not execute.
var counterModule = (function() {
	var counter = 0;
		
	return {
		incrementCounter: function () {
			 counter++;
       alert(counter++);
		},
		resetCounter: function () {
			counter = 0;
			alert("counter value prior to reset: " + counter);
		}
	};
}

counterModule.incrementCounter();
counterModule.incrementCounter();
counterModule.incrementCounter();
counterModule.resetCounter();

Open in new window


https://jsfiddle.net/isogunro/f2qjoqbs/

Thanks!
SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaac

ASKER

Thank you!