From 1882a1cdd1b84b1d2667be79b6b6afd6782075a7 Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 10:59:04 +0900 Subject: [PATCH 1/6] fix : problem01 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 분석 a++에서 ReferenceError: 변수가 선언되기 전에 접근하여 오류가 발생합니다. b += 1에서 ReferenceError: 변수가 선언되기 전에 연산하여 오류가 발생합니다. let b = 20에서 SyntaxError: 동일한 블록 내에서 let 키워드로 변수를 재선언하면 오류가 발생합니다. c = 200에서 TypeError: const로 선언된 변수는 재할당이 불가능하므로 오류가 발생합니다. 해결 방법 변수 a와 b를 선언한 후에 연산을 수행합니다. let b를 한 번만 선언합니다. const c에 값을 재할당하지 않습니다. --- problem01/problem01.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/problem01/problem01.js b/problem01/problem01.js index b2508bb..46faf3e 100644 --- a/problem01/problem01.js +++ b/problem01/problem01.js @@ -9,13 +9,12 @@ * 모든 변수 선언 및 초기화가 올바르게 이루어지도록 수정해야 테스트를 통과할 수 있습니다. */ function manageVariables() { - a++; // 🚨 - let a = 2; - b += 1; // 🚨 - let b = 10; - let b = 20; // 🚨 - const c = 100; - c = 200; // 🚨 + let a = 0; // 변수 선언 + a++; // 올바른 접근 + let b = 10; // 변수 선언 + b += 1; // 연산 수행 + const c = 100; // 변수 선언 + // c = 200; // 🚨 재할당은 불가능하므로 제거 return { a, b, c }; } module.exports = manageVariables; From c78736fca152fe7506c8c644663f1c55a5672d51 Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 11:00:19 +0900 Subject: [PATCH 2/6] fix: problem02 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 분석 sum에 덧셈 대신 뺄셈이 사용됨: a + b로 수정해야 합니다. diff에 뺄셈 대신 덧셈이 사용됨: a - b로 수정해야 합니다. product에 곱셈 대신 나눗셈이 사용됨: a * b로 수정해야 합니다. quotient에 나눗셈 대신 곱셈이 사용됨: a / b로 수정해야 합니다. remainder에 나머지 연산 대신 거듭제곱이 사용됨: a % b로 수정해야 합니다. --- problem02/problem02.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problem02/problem02.js b/problem02/problem02.js index 9b7e7c5..d5b6e8f 100644 --- a/problem02/problem02.js +++ b/problem02/problem02.js @@ -9,11 +9,11 @@ */ function calcNumbers(a, b) { return { - sum: a - b, // 🚨 - diff: a + b, // 🚨 - product: a / b, // 🚨 - quotient: a * b, // 🚨 - remainder: a ** b, // 🚨 + sum: a + b, // 덧셈 + diff: a - b, // 뺄셈 + product: a * b, // 곱셈 + quotient: a / b, // 나눗셈 + remainder: a % b, // 나머지 연산 }; } module.exports = calcNumbers; From 4910df527b2f96883d9b57accfdbf46ef71d6220 Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 11:01:25 +0900 Subject: [PATCH 3/6] fix : problem03 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 분석 및 수정 사항 looseEqual: 코드에서 ===는 엄격 동등 비교입니다. 요구사항은 느슨한 동등 비교(==)를 적용해야 하므로 수정합니다. strictEqual: 코드에서 ==는 느슨한 동등 비교입니다. 요구사항은 엄격 동등 비교(===)를 적용해야 하므로 수정합니다. notEqual: 코드에서 !=는 느슨한 부등 비교입니다. 요구사항에 따라 엄격 부등 비교(!==)로 수정합니다. greater: 현재 a < b로 잘못된 방향의 비교를 하고 있습니다. 올바른 비교는 a > b로 수정합니다. less: 현재 a > b로 잘못된 방향의 비교를 하고 있습니다. 올바른 비교는 a < b로 수정합니다. --- problem03/problem03.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problem03/problem03.js b/problem03/problem03.js index 6ab78c5..d961fc0 100644 --- a/problem03/problem03.js +++ b/problem03/problem03.js @@ -10,11 +10,11 @@ */ function compareOps(a, b) { return { - looseEqual: a === b, // 🚨 - strictEqual: a == b, // 🚨 - notEqual: a != b, // 🚨 - greater: a < b, // 🚨 - less: a > b, // 🚨 + looseEqual: a == b, // 느슨한 동등 비교 + strictEqual: a === b, // 엄격 동등 비교 + notEqual: a !== b, // 엄격 부등 비교 + greater: a > b, // a가 b보다 큰 경우 + less: a < b, // a가 b보다 작은 경우 }; } module.exports = compareOps; From 5ff3d16a67daafd0ab4496cd7743fab0157afaa9 Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 11:02:35 +0900 Subject: [PATCH 4/6] fix: problem04 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 분석 및 수정 사항 andResult: 코드에서 ||(OR 연산자)를 사용했지만, 요구사항은 &&(AND 연산자)를 적용해야 합니다. 수정: a && b. orResult: 코드에서 &&(AND 연산자)를 사용했지만, 요구사항은 ||(OR 연산자)를 적용해야 합니다. 수정: a || b. notA와 notB: 코드에서 !(NOT 연산자)가 누락되어 참/거짓 반전을 수행하지 않습니다. 수정: 각각 !a와 !b로 변경. ternary: 삼항 연산자의 조건식이 올바르지 않습니다. a && b는 두 값이 모두 참인 경우만 참이므로, 수정된 조건식은 a ? a : b로 간단히 표현합니다. 결과적으로 a가 참이면 a, 그렇지 않으면 b를 반환하도록 수정합니다. --- problem04/problem04.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problem04/problem04.js b/problem04/problem04.js index cd17510..ad2114c 100644 --- a/problem04/problem04.js +++ b/problem04/problem04.js @@ -15,11 +15,11 @@ */ function logicOps(a, b) { return { - andResult: a || b, // 🚨 - orResult: a && b, // 🚨 - notA: a, // 🚨 - notB: b, // 🚨 - ternary: a && b ? a : b, // 🚨 + andResult: a && b, // AND 연산 + orResult: a || b, // OR 연산 + notA: !a, // NOT 연산 (a 반전) + notB: !b, // NOT 연산 (b 반전) + ternary: a ? a : b, // 삼항 연산: a가 참이면 a, 아니면 b }; } module.exports = logicOps; From 4fc0f04607af2082f27b3790527d3d9f5d3d38e9 Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 11:03:41 +0900 Subject: [PATCH 5/6] fix : problem05 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 분석 및 수정 사항 typeofA: 현재 typeof b로 잘못된 변수 타입을 검사하고 있습니다. a의 타입을 검사해야 하므로 수정: typeof a. typeofB: 현재 typeof d로 잘못된 변수 타입을 검사하고 있습니다. b의 타입을 검사해야 하므로 수정: typeof b. typeofC: 현재 typeof a로 올바른 변수 타입을 검사하고 있지만, 그 위치에서 c의 타입을 검사해야 합니다. 수정: typeof c. typeofD: 현재 문자열 "null"을 반환하지만, typeof d를 사용해야 합니다. 수정: typeof d. checkNull: b가 null인지를 확인하는데 === undefined로 잘못 검사하고 있습니다. 수정: b === null. --- problem05/problem05.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/problem05/problem05.js b/problem05/problem05.js index 3801ab2..914c2ab 100644 --- a/problem05/problem05.js +++ b/problem05/problem05.js @@ -21,11 +21,11 @@ function inspectValues() { let d = "hello"; // string return { - typeofA: typeof b, // 🚨 - typeofB: typeof d, // 🚨 - typeofC: typeof a, // 🚨 - typeofD: "null", // 🚨 - checkNull: b === undefined, // 🚨 + typeofA: typeof a, // a의 타입 검사 + typeofB: typeof b, // b의 타입 검사 + typeofC: typeof c, // c의 타입 검사 + typeofD: typeof d, // d의 타입 검사 + checkNull: b === null, // b가 null인지 확인 }; } module.exports = inspectValues; From 9dbb76ec018ddb740bb7465053542ac8fe85ff7e Mon Sep 17 00:00:00 2001 From: 1000hyehyang Date: Mon, 27 Jan 2025 11:05:46 +0900 Subject: [PATCH 6/6] Update problem01.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 변경점 요약 a: let a = 1로 초기화하고 a++로 값을 증가시켜 2를 반환. b: let b = 10으로 초기화하고 b += 10로 20을 반환. c: const c = 200으로 초기화하여 기대값 200을 반환. --- problem01/problem01.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/problem01/problem01.js b/problem01/problem01.js index 46faf3e..3e1e5a9 100644 --- a/problem01/problem01.js +++ b/problem01/problem01.js @@ -9,12 +9,14 @@ * 모든 변수 선언 및 초기화가 올바르게 이루어지도록 수정해야 테스트를 통과할 수 있습니다. */ function manageVariables() { - let a = 0; // 변수 선언 - a++; // 올바른 접근 - let b = 10; // 변수 선언 - b += 1; // 연산 수행 - const c = 100; // 변수 선언 - // c = 200; // 🚨 재할당은 불가능하므로 제거 + let a = 1; // 초기값 설정 + a++; // 1 증가 + + let b = 10; // 초기값 설정 + b += 10; // 10 더하기 + + const c = 200; // 초기값 설정 + return { a, b, c }; } module.exports = manageVariables;