Edit in JSFiddle

function checkColor() {
	if(true) {
		var color = "blue";
	}
	alert(color); // blue
}

function loopScope() {
	for (var i = 0; i<10; i++) {
		//반복 실행할 코드
	}
	alert(i); // 10
}
<button type="button" onclick="checkColor()">색 확인</button>
<button type="button" onclick="loopScope()">반복문의 i는?</button>