Last active
August 29, 2015 14:18
-
-
Save ibare/340518430231efe2204a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var etLanList = { | |
변수 : '변수는 값의 위치를 기억하는 저장소이다', | |
조건문 : '조건문은 값을 비교하여 실행 흐름을 변경하는 기능을 한다', | |
반복문 : '반복문은 같은 패턴을 반복되는 조건에서 실행하는 기능을 한다', | |
배열 : '배열은 하나의 이름을 공유하는 연속된 값들의 목록이다', | |
객체 : '객체는 이름을 공유하는 연속되지 않은 값들의 목록이다', | |
함수 : '함수는 코드의 묶음이고 이름을 호출하여 실행한다' | |
}; | |
/* | |
변수명을 좀 더 의미있게 했으면 좋겠어요. | |
answer0 는 답변해줄 목록이니 programmingKeywordList 같은식의 이림이면 좋겠고 | |
answer1 은 계속 할것인지에 대한 답변을 담을 것이니까 tryAgain 라거나... | |
*/ | |
var answer0 = ['변수', '조건문', '반복문', '배열', '객체', '함수']; | |
var answer; | |
/* 함수명도 역시 의미 있게 지었으면... */ | |
var func1 = function(a) { | |
confirm(a); | |
}; | |
alert('외계어 스터디에서 배운 내용을 확인해 봅시다'); | |
do{ | |
answer = prompt('변수 조건문 반복문 배열 객체 함수 총 6개 개념에 대해 알 수 있습니다. 궁금한 내용의 단어를 입력해 주세요'); | |
if(answer == answer0[0]){ | |
alert(etLanList.변수); | |
} else if(answer ==answer0[1]){ | |
alert(etLanList.조건문); | |
} else if(answer ==answer0[2]){ | |
alert(etLanList.반복문); | |
} else if(answer ==answer0[3]){ | |
alert(etLanList.배열); | |
} else if(answer ==answer0[4]){ | |
alert(etLanList.객체); | |
} else{ | |
alert(etLanList.함수); | |
} | |
/* | |
func1 은 왜 함수로 만든건가요? | |
confirm 을 호출하는 역할을 하는데 새로운 기능이 있는 것도 아니고 편리함을 주는 부분도 없어서 | |
불필요하게 함수로 만들어진 것 같습니다. | |
var answer1 = confirm('또 물어볼래요?'); 와 비교해 보세요. | |
*/ | |
var answer1 = func1('또 물어볼래요?'); | |
} while(answer1 == true); | |
/* | |
아니오를 선택해도 계속 반복되었던건 while(answer = true) 로 되어있었기 때문이에요. | |
대입문으로 되어있어서 언제나 true 였죠. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var etLanList = { | |
변수 : '변수는 값의 위치를 기억하는 저장소이다', | |
조건문 : '조건문은 값을 비교하여 실행 흐름을 변경하는 기능을 한다', | |
반복문 : '반복문은 같은 패턴을 반복되는 조건에서 실행하는 기능을 한다', | |
배열 : '배열은 하나의 이름을 공유하는 연속된 값들의 목록이다', | |
객체 : '객체는 이름을 공유하는 연속되지 않은 값들의 목록이다', | |
함수 : '함수는 코드의 묶음이고 이름을 호출하여 실행한다' | |
}; | |
var programmingKeywordList = ['변수', '조건문', '반복문', '배열', '객체', '함수']; | |
var answer; | |
alert('외계어 스터디에서 배운 내용을 확인해 봅시다.'); | |
do{ | |
answer = prompt('변수 조건문 반복문 배열 객체 함수 총 6개 개념에 대해 알 수 있습니다. 궁금한 내용의 단어를 입력해 주세요'); | |
if(etLanList.hasOwnProperty(answer) == true) { | |
alert(etLanList[answer]); | |
} else { | |
var possibleList = ''; | |
for(var i=0; i < programmingKeywordList.length; i++) { | |
possibleList = possibleList + programmingKeywordList[i] + ', '; | |
} | |
alert(possibleList + '중에서만 답변할 수 있습니다.'); | |
} | |
} while(confirm('또 물어볼래요?')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var etLanList = { | |
변수 : '변수는 값의 위치를 기억하는 저장소이다', | |
조건문 : '조건문은 값을 비교하여 실행 흐름을 변경하는 기능을 한다', | |
반복문 : '반복문은 같은 패턴을 반복되는 조건에서 실행하는 기능을 한다', | |
배열 : '배열은 하나의 이름을 공유하는 연속된 값들의 목록이다', | |
객체 : '객체는 이름을 공유하는 연속되지 않은 값들의 목록이다', | |
함수 : '함수는 코드의 묶음이고 이름을 호출하여 실행한다' | |
}; | |
var programmingKeywordList = ['변수', '조건문', '반복문', '배열', '객체', '함수']; | |
var answer; | |
alert('외계어 스터디에서 배운 내용을 확인해 봅시다.'); | |
do{ | |
answer = prompt(programmingKeywordList.join(',') + ' 총 6개 개념에 대해 알 수 있습니다. 궁금한 내용의 단어를 입력해 주세요'); | |
if(etLanList.hasOwnProperty(answer) == true) { | |
alert(etLanList[answer]); | |
} else { | |
alert(programmingKeywordList.join(',') + ' 중에서만 답변할 수 있습니다.'); | |
} | |
} while(confirm('또 물어볼래요?')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var etLanList = [ | |
{ keyword: '변수', description: '변수는 값의 위치를 기억하는 저장소이다' }, | |
{ keyword: '조건문', description: '조건문은 값을 비교하여 실행 흐름을 변경하는 기능을 한다' }, | |
{ keyword: '반복문', description: '반복문은 같은 패턴을 반복되는 조건에서 실행하는 기능을 한다' }, | |
{ keyword: '배열', description: '배열은 하나의 이름을 공유하는 연속된 값들의 목록이다' }, | |
{ keyword: '객체', description: '객체는 이름을 공유하는 연속되지 않은 값들의 목록이다' }, | |
{ keyword: '함수', description: '함수는 코드의 묶음이고 이름을 호출하여 실행한다' } | |
]; | |
var answer; | |
function displayKeywordList() { | |
var keywordList = []; | |
for(var i=0; i < etLanList.length; i++) { | |
keywordList[i] = etLanList[i].keyword; | |
} | |
return keywordList.join(','); | |
} | |
function matchKeyword(answer) { | |
for(var i=0; i < etLanList.length; i++) { | |
if(etLanList[i].keyword == answer) { | |
alert(etLanList[i].description); | |
return true; | |
} | |
} | |
return false; | |
} | |
alert('외계어 스터디에서 배운 내용을 확인해 봅시다.'); | |
do{ | |
answer = prompt(displayKeywordList() + ' 총 6개 개념에 대해 알 수 있습니다. 궁금한 내용의 단어를 입력해 주세요'); | |
if(matchKeyword(answer) == false) { | |
alert(displayKeywordList() + ' 중에서만 답변할 수 있습니다.'); | |
} | |
} while(confirm('또 물어볼래요?')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var etLanList = [ | |
{ keyword: '변수', description: '변수는 값의 위치를 기억하는 저장소이다' }, | |
{ keyword: '조건문', description: '조건문은 값을 비교하여 실행 흐름을 변경하는 기능을 한다' }, | |
{ keyword: '반복문', description: '반복문은 같은 패턴을 반복되는 조건에서 실행하는 기능을 한다' }, | |
{ keyword: '배열', description: '배열은 하나의 이름을 공유하는 연속된 값들의 목록이다' }, | |
{ keyword: '객체', description: '객체는 이름을 공유하는 연속되지 않은 값들의 목록이다' }, | |
{ keyword: '함수', description: '함수는 코드의 묶음이고 이름을 호출하여 실행한다' } | |
]; | |
var answer, description; | |
function displayKeywordList(source) { | |
var keywordList = []; | |
for(var i=0; i < source.length; i++) { | |
keywordList[i] = source[i].keyword; | |
} | |
return keywordList.join(','); | |
} | |
function matchKeyword(source, answer) { | |
for(var i=0; i < source.length; i++) { | |
if(source[i].keyword == answer) { | |
return source[i].description; | |
} | |
} | |
return ''; | |
} | |
alert('외계어 스터디에서 배운 내용을 확인해 봅시다.'); | |
do{ | |
answer = prompt(displayKeywordList(etLanList) + ' 총 ' + etLanList.length + '개 개념에 대해 알 수 있습니다. 궁금한 내용의 단어를 입력해 주세요'); | |
description = matchKeyword(etLanList, answer); | |
if(description == '') { | |
alert(displayKeywordList(etLanList) + ' 중에서만 답변할 수 있습니다.'); | |
} else { | |
alert(description); | |
} | |
} while(confirm('또 물어볼래요?')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment