var counter = 0; function show_counter () { console.log(counter) }; function plus_counter () { counter == 2 ? counter = 0 : counter++; show_counter(); };