JSFiddle - React, Tailwind, and code Playground

by matox

JavaScript

let c = 0;	// A
const count = () => {		// B
  return (function() {
    return c++;
  })();
};

console.log(count() === 0);
console.log(count() === 1);
console.log(count() === 2);

/*
	QUESTIONS:	
	- Can we rewrite function in a way that "A" is inside of "B"?
  	- With each call to "B" we set a new state of variable c.
*/