js
CHAPTER 34 / 34
읽기 약 2분
FUNCTION
JS 최종 미션 — 완전 해체
핵심 개념
지금까지 학습한 모든 JS 개념이 하나의 미니 앱에 통합되어 있습니다. 클로저, 비동기, DOM 조작, 이벤트, 배열 메서드가 모두 사용됩니다. 각 함수와 이벤트 리스너를 하나씩 제거하며 시스템이 어떻게 붕괴되는지 확인하십시오. 모든 기능을 완전히 제거하여 MISSION COMPLETE를 달성하십시오.
코드 분석
<div style='font-family:monospace; padding:16px; background:#0d1117; color:#e8e8e8;'>
<div style='display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;'>
<span style='color:#10b981; font-weight:bold;'>TERMINATOR UNIT TRACKER</span>
<span id='total-threat' style='color:#888; font-size:11px;'>TOTAL THREAT: 0</span>
</div>
<div id='unit-list' style='margin-bottom:12px;'></div>
<div style='display:flex; gap:8px;'>
<input id='unit-input' placeholder='유닛명 입력...' style='flex:1; padding:8px; background:#1a1a1a; color:#e8e8e8; border:1px solid #333; font-family:monospace;'/>
<button onclick='addUnit()' style='padding:8px 16px; background:#10b981; color:#080808; border:none; cursor:pointer; font-family:monospace; font-weight:bold;'>ADD</button>
</div>
</div>
<script>
const createUnitManager = () => {
let units = [
{ name: 'T-800', threat: 8, active: true },
{ name: 'T-1000', threat: 10, active: true },
];
const render = () => {
const list = document.getElementById('unit-list');
const totalEl = document.getElementById('total-threat');
const total = units.filter(u=>u.active).reduce((s,u)=>s+u.threat,0);
totalEl.textContent = 'TOTAL THREAT: ' + total;
list.innerHTML = units.map((u, i) =>
'<div style="display:flex;justify-content:space-between;align-items:center;padding:6px 8px;margin-bottom:4px;background:' + (u.active?'#1a0000':'#0a0a0a') + ';border:1px solid ' + (u.active?'#10b98144':'#1a1a1a') + ';">' +
'<span style="color:' + (u.active?'#10b981':'#333') + ';">' + u.name + '</span>' +
'<span style="color:#555;font-size:11px;">THREAT:' + u.threat + '</span>' +
'<button onclick="manager.toggle(' + i + ')" style="padding:2px 8px;background:transparent;border:1px solid #333;color:#555;cursor:pointer;font-family:monospace;font-size:10px;">' + (u.active?'DEACTIVATE':'ACTIVATE') + '</button>' +
'</div>'
).join('');
};
return {
add: (name) => {
units.push({ name, threat: Math.floor(Math.random()*5)+5, active: true });
render();
},
toggle: (i) => { units[i].active = !units[i].active; render(); },
};
};
const manager = createUnitManager();
manager.add = manager.add;
function addUnit() {
const input = document.getElementById('unit-input');
if (input.value.trim()) {
manager.add(input.value.trim());
input.value = '';
}
}
document.getElementById('unit-input').addEventListener('keydown', e => {
if (e.key === 'Enter') addUnit();
});
const manager2 = createUnitManager();
document.getElementById('unit-list') && manager2.add('');
const m = createUnitManager();
m.toggle(0);
const mgr = createUnitManager();
mgr.add('T-X');
setTimeout(() => {
document.getElementById('total-threat') && mgr.toggle(0);
}, 100);
</script>AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude
무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6
이 JS '최종 미션' 코드의 잠재적 버그와 메모리 누수·this 바인딩·비동기 경합 위험을 분석해서 프로덕션 수준으로 개선해줘.
ChatGPT
무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro
'최종 미션'를 실제 서비스에서 어떻게 쓰는지 구체적 사례 3개와 복사 가능한 코드를 초보자가 이해할 수 있게 보여줘.
Gemini
무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro
이 JS '최종 미션' 관련 코드 전체의 실행 흐름을 분석하고 성능 병목과 최적화 방안을 우선순위로 알려줘.
Grok
무료: Grok 4.1 / SuperGrok $30/mo
'최종 미션'에서 개발자들이 가장 많이 하는 실수 Top 3을 솔직하게 알려주고 2026년 권장 패턴을 함께 알려줘.
⭐ 이것만 기억하세요
JS 최종 미션 — 완전 해체는 이 3가지만 확실히 잡으세요
1.개별 문법을 각각 알아도 DOM 조작 + 비동기 + 이벤트를 조합하지 못하면 실제 동작하는 앱을 만들 수 없습니다
2.fetch로 데이터를 가져오고, DOM으로 화면에 그리고, 이벤트로 사용자 행동에 반응하는 것이 JavaScript 종합 설계입니다
3.JavaScript 트랙을 마쳤습니다 — 다음은 React 트랙에서 컴포넌트 기반 UI 개발을 배웁니다
공유하기
진행도 34 / 34