You can also space some lines and change line 4-5 to:
item.style.visibility = (item.style.visibility == 'visible') ? 'hidden' : 'visible';