Ваша проблема в том, что начальное значение цвета фона на элементе не установлено. Элемент 1 имеет белый цвет фона из стиля css идентификатора. Но item1.style.backgroundColor вернет только значение, установленное непосредственно на встроенном элементе.
var item1 = document.getElementById('item1');
function setColor(){
if (!item1.style.backgroundColor || item1.style.backgroundColor == 'white'){
item1.style.backgroundColor = 'green';
} else if (item1.style.backgroundColor == 'green'){
item1.style.backgroundColor = 'white';
}
}
item1.addEventListener('click', function(){setColor()}, false);
#testList {
width: 100px;
background-color: grey;
margin: 200px 0px 0px 50px;
list-style-type: none;
}
#testList li {
color: black;
padding: 10px;
border: 1px solid black;
}
#testList li:hover{cursor: pointer;}
#item1 {background-color: white;}
<ul id="testList"> Test List
<li id="item1">Item 1</li>
<li id="item2">Item 2</li>
</ul>