diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..e876579 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,7 @@ +module.exports = { + plugins: [ + require('tailwindcss'), + require('autoprefixer'), + ], + } + \ No newline at end of file diff --git "a/\352\271\200\352\260\200\354\227\260/ex1/book-edit.html" "b/\352\271\200\352\260\200\354\227\260/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\352\260\200\354\227\260/ex1/index.html" "b/\352\271\200\352\260\200\354\227\260/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\352\260\200\354\227\260/ex1/register.html" "b/\352\271\200\352\260\200\354\227\260/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\352\260\200\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\352\260\200\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\352\260\200\354\227\260/ex10.test.ts" "b/\352\271\200\352\260\200\354\227\260/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\352\260\200\354\227\260/ex10.ts" "b/\352\271\200\352\260\200\354\227\260/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\352\260\200\354\227\260/ex2.js" "b/\352\271\200\352\260\200\354\227\260/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\352\260\200\354\227\260/ex2.test.js" "b/\352\271\200\352\260\200\354\227\260/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\352\260\200\354\227\260/ex3.js" "b/\352\271\200\352\260\200\354\227\260/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\352\260\200\354\227\260/ex3.test.js" "b/\352\271\200\352\260\200\354\227\260/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\352\260\200\354\227\260/ex4.js" "b/\352\271\200\352\260\200\354\227\260/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\352\260\200\354\227\260/ex4.test.js" "b/\352\271\200\352\260\200\354\227\260/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\352\260\200\354\227\260/ex5.js" "b/\352\271\200\352\260\200\354\227\260/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\352\260\200\354\227\260/ex5.test.js" "b/\352\271\200\352\260\200\354\227\260/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\352\260\200\354\227\260/ex6.test.ts" "b/\352\271\200\352\260\200\354\227\260/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\352\260\200\354\227\260/ex6.ts" "b/\352\271\200\352\260\200\354\227\260/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\352\260\200\354\227\260/ex7.test.ts" "b/\352\271\200\352\260\200\354\227\260/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\352\260\200\354\227\260/ex7.ts" "b/\352\271\200\352\260\200\354\227\260/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\352\260\200\354\227\260/ex8.ts" "b/\352\271\200\352\260\200\354\227\260/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\352\260\200\354\227\260/ex9.js" "b/\352\271\200\352\260\200\354\227\260/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\352\260\200\354\227\260/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\353\217\231\354\227\260/ex1/book-edit.html" "b/\352\271\200\353\217\231\354\227\260/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\227\260/ex1/index.html" "b/\352\271\200\353\217\231\354\227\260/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\227\260/ex1/register.html" "b/\352\271\200\353\217\231\354\227\260/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\353\217\231\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\353\217\231\354\227\260/ex10.test.ts" "b/\352\271\200\353\217\231\354\227\260/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\353\217\231\354\227\260/ex10.ts" "b/\352\271\200\353\217\231\354\227\260/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\353\217\231\354\227\260/ex2.js" "b/\352\271\200\353\217\231\354\227\260/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\353\217\231\354\227\260/ex2.test.js" "b/\352\271\200\353\217\231\354\227\260/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\353\217\231\354\227\260/ex3.js" "b/\352\271\200\353\217\231\354\227\260/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\353\217\231\354\227\260/ex3.test.js" "b/\352\271\200\353\217\231\354\227\260/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\353\217\231\354\227\260/ex4.js" "b/\352\271\200\353\217\231\354\227\260/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\353\217\231\354\227\260/ex4.test.js" "b/\352\271\200\353\217\231\354\227\260/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\353\217\231\354\227\260/ex5.js" "b/\352\271\200\353\217\231\354\227\260/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\353\217\231\354\227\260/ex5.test.js" "b/\352\271\200\353\217\231\354\227\260/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\353\217\231\354\227\260/ex6.test.ts" "b/\352\271\200\353\217\231\354\227\260/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\353\217\231\354\227\260/ex6.ts" "b/\352\271\200\353\217\231\354\227\260/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\353\217\231\354\227\260/ex7.test.ts" "b/\352\271\200\353\217\231\354\227\260/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\353\217\231\354\227\260/ex7.ts" "b/\352\271\200\353\217\231\354\227\260/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\353\217\231\354\227\260/ex8.ts" "b/\352\271\200\353\217\231\354\227\260/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\353\217\231\354\227\260/ex9.js" "b/\352\271\200\353\217\231\354\227\260/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\353\217\231\354\227\260/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\353\217\231\354\235\200/ex1/book-edit.html" "b/\352\271\200\353\217\231\354\235\200/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\235\200/ex1/index.html" "b/\352\271\200\353\217\231\354\235\200/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\235\200/ex1/register.html" "b/\352\271\200\353\217\231\354\235\200/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\217\231\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\353\217\231\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\353\217\231\354\235\200/ex10.test.ts" "b/\352\271\200\353\217\231\354\235\200/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\353\217\231\354\235\200/ex10.ts" "b/\352\271\200\353\217\231\354\235\200/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\353\217\231\354\235\200/ex2.js" "b/\352\271\200\353\217\231\354\235\200/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\353\217\231\354\235\200/ex2.test.js" "b/\352\271\200\353\217\231\354\235\200/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\353\217\231\354\235\200/ex3.js" "b/\352\271\200\353\217\231\354\235\200/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\353\217\231\354\235\200/ex3.test.js" "b/\352\271\200\353\217\231\354\235\200/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\353\217\231\354\235\200/ex4.js" "b/\352\271\200\353\217\231\354\235\200/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\353\217\231\354\235\200/ex4.test.js" "b/\352\271\200\353\217\231\354\235\200/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\353\217\231\354\235\200/ex5.js" "b/\352\271\200\353\217\231\354\235\200/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\353\217\231\354\235\200/ex5.test.js" "b/\352\271\200\353\217\231\354\235\200/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\353\217\231\354\235\200/ex6.test.ts" "b/\352\271\200\353\217\231\354\235\200/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\353\217\231\354\235\200/ex6.ts" "b/\352\271\200\353\217\231\354\235\200/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\353\217\231\354\235\200/ex7.test.ts" "b/\352\271\200\353\217\231\354\235\200/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\353\217\231\354\235\200/ex7.ts" "b/\352\271\200\353\217\231\354\235\200/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\353\217\231\354\235\200/ex8.ts" "b/\352\271\200\353\217\231\354\235\200/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\353\217\231\354\235\200/ex9.js" "b/\352\271\200\353\217\231\354\235\200/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\353\217\231\354\235\200/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\353\257\270\352\260\225/ex1/book-edit.html" "b/\352\271\200\353\257\270\352\260\225/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\257\270\352\260\225/ex1/index.html" "b/\352\271\200\353\257\270\352\260\225/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\257\270\352\260\225/ex1/register.html" "b/\352\271\200\353\257\270\352\260\225/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\353\257\270\352\260\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\353\257\270\352\260\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\353\257\270\352\260\225/ex10.test.ts" "b/\352\271\200\353\257\270\352\260\225/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\353\257\270\352\260\225/ex10.ts" "b/\352\271\200\353\257\270\352\260\225/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\353\257\270\352\260\225/ex2.js" "b/\352\271\200\353\257\270\352\260\225/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\353\257\270\352\260\225/ex2.test.js" "b/\352\271\200\353\257\270\352\260\225/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\353\257\270\352\260\225/ex3.js" "b/\352\271\200\353\257\270\352\260\225/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\353\257\270\352\260\225/ex3.test.js" "b/\352\271\200\353\257\270\352\260\225/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\353\257\270\352\260\225/ex4.js" "b/\352\271\200\353\257\270\352\260\225/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\353\257\270\352\260\225/ex4.test.js" "b/\352\271\200\353\257\270\352\260\225/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\353\257\270\352\260\225/ex5.js" "b/\352\271\200\353\257\270\352\260\225/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\353\257\270\352\260\225/ex5.test.js" "b/\352\271\200\353\257\270\352\260\225/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\353\257\270\352\260\225/ex6.test.ts" "b/\352\271\200\353\257\270\352\260\225/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\353\257\270\352\260\225/ex6.ts" "b/\352\271\200\353\257\270\352\260\225/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\353\257\270\352\260\225/ex7.test.ts" "b/\352\271\200\353\257\270\352\260\225/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\353\257\270\352\260\225/ex7.ts" "b/\352\271\200\353\257\270\352\260\225/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\353\257\270\352\260\225/ex8.ts" "b/\352\271\200\353\257\270\352\260\225/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\353\257\270\352\260\225/ex9.js" "b/\352\271\200\353\257\270\352\260\225/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\353\257\270\352\260\225/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\354\203\201\355\230\204/ex1/book-edit.html" "b/\352\271\200\354\203\201\355\230\204/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\203\201\355\230\204/ex1/index.html" "b/\352\271\200\354\203\201\355\230\204/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\203\201\355\230\204/ex1/register.html" "b/\352\271\200\354\203\201\355\230\204/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\203\201\355\230\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\354\203\201\355\230\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\354\203\201\355\230\204/ex10.test.ts" "b/\352\271\200\354\203\201\355\230\204/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\354\203\201\355\230\204/ex10.ts" "b/\352\271\200\354\203\201\355\230\204/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\354\203\201\355\230\204/ex2.js" "b/\352\271\200\354\203\201\355\230\204/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\354\203\201\355\230\204/ex2.test.js" "b/\352\271\200\354\203\201\355\230\204/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\354\203\201\355\230\204/ex3.js" "b/\352\271\200\354\203\201\355\230\204/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\354\203\201\355\230\204/ex3.test.js" "b/\352\271\200\354\203\201\355\230\204/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\354\203\201\355\230\204/ex4.js" "b/\352\271\200\354\203\201\355\230\204/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\354\203\201\355\230\204/ex4.test.js" "b/\352\271\200\354\203\201\355\230\204/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\354\203\201\355\230\204/ex5.js" "b/\352\271\200\354\203\201\355\230\204/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\354\203\201\355\230\204/ex5.test.js" "b/\352\271\200\354\203\201\355\230\204/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\354\203\201\355\230\204/ex6.test.ts" "b/\352\271\200\354\203\201\355\230\204/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\354\203\201\355\230\204/ex6.ts" "b/\352\271\200\354\203\201\355\230\204/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\354\203\201\355\230\204/ex7.test.ts" "b/\352\271\200\354\203\201\355\230\204/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\354\203\201\355\230\204/ex7.ts" "b/\352\271\200\354\203\201\355\230\204/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\354\203\201\355\230\204/ex8.ts" "b/\352\271\200\354\203\201\355\230\204/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\354\203\201\355\230\204/ex9.js" "b/\352\271\200\354\203\201\355\230\204/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\354\203\201\355\230\204/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\354\204\261\354\247\204/ex1/book-edit.html" "b/\352\271\200\354\204\261\354\247\204/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\204\261\354\247\204/ex1/index.html" "b/\352\271\200\354\204\261\354\247\204/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\204\261\354\247\204/ex1/register.html" "b/\352\271\200\354\204\261\354\247\204/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\204\261\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\354\204\261\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\354\204\261\354\247\204/ex10.test.ts" "b/\352\271\200\354\204\261\354\247\204/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\354\204\261\354\247\204/ex10.ts" "b/\352\271\200\354\204\261\354\247\204/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\354\204\261\354\247\204/ex2.js" "b/\352\271\200\354\204\261\354\247\204/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\354\204\261\354\247\204/ex2.test.js" "b/\352\271\200\354\204\261\354\247\204/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\354\204\261\354\247\204/ex3.js" "b/\352\271\200\354\204\261\354\247\204/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\354\204\261\354\247\204/ex3.test.js" "b/\352\271\200\354\204\261\354\247\204/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\354\204\261\354\247\204/ex4.js" "b/\352\271\200\354\204\261\354\247\204/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\354\204\261\354\247\204/ex4.test.js" "b/\352\271\200\354\204\261\354\247\204/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\354\204\261\354\247\204/ex5.js" "b/\352\271\200\354\204\261\354\247\204/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\354\204\261\354\247\204/ex5.test.js" "b/\352\271\200\354\204\261\354\247\204/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\354\204\261\354\247\204/ex6.test.ts" "b/\352\271\200\354\204\261\354\247\204/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\354\204\261\354\247\204/ex6.ts" "b/\352\271\200\354\204\261\354\247\204/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\354\204\261\354\247\204/ex7.test.ts" "b/\352\271\200\354\204\261\354\247\204/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\354\204\261\354\247\204/ex7.ts" "b/\352\271\200\354\204\261\354\247\204/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\354\204\261\354\247\204/ex8.ts" "b/\352\271\200\354\204\261\354\247\204/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\354\204\261\354\247\204/ex9.js" "b/\352\271\200\354\204\261\354\247\204/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\354\204\261\354\247\204/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\354\235\270\354\230\201/ex1/book-edit.html" "b/\352\271\200\354\235\270\354\230\201/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\235\270\354\230\201/ex1/index.html" "b/\352\271\200\354\235\270\354\230\201/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\235\270\354\230\201/ex1/register.html" "b/\352\271\200\354\235\270\354\230\201/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\354\235\270\354\230\201/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\354\235\270\354\230\201/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\354\235\270\354\230\201/ex10.test.ts" "b/\352\271\200\354\235\270\354\230\201/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\354\235\270\354\230\201/ex10.ts" "b/\352\271\200\354\235\270\354\230\201/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\354\235\270\354\230\201/ex2.js" "b/\352\271\200\354\235\270\354\230\201/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\354\235\270\354\230\201/ex2.test.js" "b/\352\271\200\354\235\270\354\230\201/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\354\235\270\354\230\201/ex3.js" "b/\352\271\200\354\235\270\354\230\201/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\354\235\270\354\230\201/ex3.test.js" "b/\352\271\200\354\235\270\354\230\201/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\354\235\270\354\230\201/ex4.js" "b/\352\271\200\354\235\270\354\230\201/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\354\235\270\354\230\201/ex4.test.js" "b/\352\271\200\354\235\270\354\230\201/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\354\235\270\354\230\201/ex5.js" "b/\352\271\200\354\235\270\354\230\201/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\354\235\270\354\230\201/ex5.test.js" "b/\352\271\200\354\235\270\354\230\201/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\354\235\270\354\230\201/ex6.test.ts" "b/\352\271\200\354\235\270\354\230\201/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\354\235\270\354\230\201/ex6.ts" "b/\352\271\200\354\235\270\354\230\201/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\354\235\270\354\230\201/ex7.test.ts" "b/\352\271\200\354\235\270\354\230\201/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\354\235\270\354\230\201/ex7.ts" "b/\352\271\200\354\235\270\354\230\201/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\354\235\270\354\230\201/ex8.ts" "b/\352\271\200\354\235\270\354\230\201/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\354\235\270\354\230\201/ex9.js" "b/\352\271\200\354\235\270\354\230\201/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\354\235\270\354\230\201/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\352\271\200\354\261\204\354\232\264/ex1/book-edit.html" "b/\352\271\200\354\261\204\354\232\264/ex1/book-edit.html" index e69de29..e1e687f 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex1/book-edit.html" +++ "b/\352\271\200\354\261\204\354\232\264/ex1/book-edit.html" @@ -0,0 +1,159 @@ + + + + + + + + + + + + +
+ +
+ + + | + +
+
+ + +
+
+
+ +
+
+ + +
+
+ + + +
+

There is no marks.

+
+ +
+ + +
+ © Hanaro 2024 +
+ + + + + \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex1/index.css" "b/\352\271\200\354\261\204\354\232\264/ex1/index.css" new file mode 100644 index 0000000..bd6213e --- /dev/null +++ "b/\352\271\200\354\261\204\354\232\264/ex1/index.css" @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex1/index.html" "b/\352\271\200\354\261\204\354\232\264/ex1/index.html" index e69de29..0ccb9d0 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex1/index.html" +++ "b/\352\271\200\354\261\204\354\232\264/ex1/index.html" @@ -0,0 +1,286 @@ + + + + + + + + + + + + +
+ +
+ + +
+
+ + +
+
+
    +

    Bookmark

    +
  • + Bookmark Image +
    + Google + 구글에서 다양한 검색을... +
    +
    + +
    +
  • +
  • + Bookmark Image +
    + Naver + 다양한 정보와 유용한 컨텐츠를 + 만나보세요... +
    +
    + +
    +
  • +
  • + Bookmark Image +
    + Youtube + 마음에 드는 동영상과 음악을 + 감상하고... +
    +
    + +
    +
  • + +
+ +
+ +
+
+ +
+
    +

    Study

    +
  • + Bookmark Image +
    + JavaScript + Programming language of + the Web... +
    +
    + +
    +
  • + +
  • + Bookmark Image +
    + Tailwind CSS + Tailwind CSS is + a... +
    +
    + +
    +
  • + +
+ +
+ +
+
+
+ + +
+ © Hanaro 2024 +
+ + + + + \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex1/register.html" "b/\352\271\200\354\261\204\354\232\264/ex1/register.html" index e69de29..a54d633 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex1/register.html" +++ "b/\352\271\200\354\261\204\354\232\264/ex1/register.html" @@ -0,0 +1,129 @@ + + + + + + + + + + + + +
+ +
+ + + | + +
+
+ + +
+
+

🔮Sign Up🌠

+
+ + + + + + + + +
+ +
+ + +
+ + +
+ © Hanaro 2024 +
+ + + + + \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex10.test.ts" "b/\352\271\200\354\261\204\354\232\264/ex10.test.ts" index 6218a79..27b8308 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex10.test.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex10.test.ts" @@ -1,4 +1,25 @@ import { ArrayList } from './ex10'; console.log('🚀 ArrayList:', ArrayList); -// 여기에 테스트코드를 작성하세요. +const alist = new ArrayList([1, 2]); // alist.toString() ⇒ { value: 1, rest: { value: 2 } } +console.log(alist.listToArray(({ value: 1, rest: { value: 2 } }))); +console.log(alist.arrayToList([1,2])); +console.log(alist.add(3)); +console.log(alist.add(5, 1)); +console.log(alist.indexOf(3)); +console.log(alist.indexOf(900)); //존재하지 않는 값의 인덱스 검색시 -1 반환 +console.log(alist.remove(2)); +console.log(alist.add(22, 1)); +console.log(alist.add(33, 1)); +console.log(alist.toString()); +console.log(alist.set(1, 300)); +console.log(alist.get(2)); +console.log(alist.size()); +console.log(alist.contains(300)); +console.log(alist.contains(301)); +console.log(alist.isEmpty()); +console.log(alist.peek()); +console.log(alist.toArray()); +console.log(alist.iterator().next()); +console.log(alist.clear()); +console.log(alist.isEmpty()); //true , clear이후 비어있음. diff --git "a/\352\271\200\354\261\204\354\232\264/ex10.ts" "b/\352\271\200\354\261\204\354\232\264/ex10.ts" index 1ffaef5..e750596 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex10.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex10.ts" @@ -14,41 +14,18 @@ class Collection { return this.arr; } - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - get poll(): T | undefined { return this.isQueue() ? this.arr.shift() : this.arr.pop(); } - remove() { - return this.poll; - } - get length() { return this.arr.length; } - get isEmpty() { - return !this.arr.length; - } - clear() { this.arr.length = 0; } - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - toArray() { return this.isQueue() ? this.arr.toReversed() : this.arr; } @@ -65,7 +42,137 @@ class Collection { class Stack extends Collection {} class Queue extends Collection {} -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} +interface MyNode { + value: T; + rest?: MyNode; +} + +class ArrayList extends Collection { + constructor(arr: T[] = []) { + super(...arr); + } + + toString(): string { + const node = this.arrayToList(this._arr); + return this.nodeToString(node); + } + + private nodeToString(node?: MyNode): string { + if (!node) return ""; + + const { value, rest } = node; + return rest + ? `{ value: ${value}, rest: ${this.nodeToString(rest)} }` + : `{ value: ${value} }`; + } + + arrayToList(arr: T[]): MyNode | undefined { + if (arr.length === 0) return undefined; + + const [first, ...rest] = arr; + const node: MyNode = { value: first }; + const restNode = this.arrayToList(rest); + + if (restNode) { + node.rest = restNode; + } + + return node; + } + + listToArray(node: MyNode | undefined): T[] { + const result: T[] = []; + while (node) { + result.push(node.value); + node = node.rest; + } + return result; + } + + toArray(): T[] { + return [...this._arr]; + } + + add(value: T, index?: number): string { + if (index === undefined) { + this.push(value); // 인덱스가 지정되지 않은 경우, 배열의 끝에 추가 + } else { + this._arr.splice(index, 0, value); // 지정된 인덱스에 값 추가 + } + return this.toString(); // 추가 후 결과를 문자열로 반환 + } + + remove(value: T): string | undefined { + let idx = this.indexOf(value); + + if (idx === -1) { + //존재하지 않는 값을 삭제하려는 경우 + return "존재하지 않는 값입니다."; + } else { + this._arr.splice(idx, 1); + return this.toString(); + } + } + + indexOf(value: T): number { + let cnt = 0; + for (let v of this._arr.values()) { + if (v === value) return cnt; + cnt += 1; + } + return -1; //존재하지 않으면 -1반환 + } + + set(index: number, value: T): string { + this._arr[index] = value; + return this.toString(); + } + + get(index: number): T | undefined { + if (index < 0 || index >= this.length) { + return undefined; + } + return this._arr[index]; + } + + size(): number { + return this.length; + } + + contains(value: T): boolean { + return this._arr.includes(value) === true; + } + + isEmpty(): boolean { + if (this.length === 0) { + return true; + } else { + return false; + } + } + + peek(): T { + return this._arr[-1]; + } + + iterator() { + let index = 0; + const arr = this.toArray(); + return { + next: () => { + if (index < arr.length) { + return { value: arr[index++], done: false }; + } else { + return { value: undefined, done: true }; + } + }, + }; + } + + clear(): string { + this._arr.length = 0; + return "all clear"; + } +} export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\354\261\204\354\232\264/ex2.js" "b/\352\271\200\354\261\204\354\232\264/ex2.js" index 6b95f04..3d2583f 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex2.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex2.js" @@ -1,4 +1,49 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; +const range = (start, end, step = start > end ? -1 : 1) => { + // 인자가 하나만 주어진 경우: end는 start가 됨, start는 1 또는 음수 + if (end === undefined) { + if (start === 0) { + return [0]; + } + end = start < 0 ? -1 : start; + start = start < 0 ? start : 1; // 음수일 경우 그대로 사용하고, 양수일 경우 1부터 시작 + } + + if (step === 0) { + return [start]; + } + + const result = []; + + // 소수점 처리 + const precision = Math.max( + (step.toString().split('.')[1] || '').length, + (start.toString().split('.')[1] || '').length, + (end.toString().split('.')[1] || '').length + ); + + const x = Math.pow(10, precision); + start = Math.round(start * x); + end = Math.round(end * x); + step = Math.round(step * x); + + // step이 양수일 때 + if (step > 0) { + if (start <= end) { + for (let i = start; i <= end; i += step) { + result.push(parseFloat((i / x).toFixed(precision))); + } + } + } + // step이 음수일 때 + else { + if (start >= end) { + for (let i = start; i >= end; i += step) { + result.push(parseFloat((i / x).toFixed(precision))); + } + } + } + + return result; +}; module.exports = { range }; diff --git "a/\352\271\200\354\261\204\354\232\264/ex2.test.js" "b/\352\271\200\354\261\204\354\232\264/ex2.test.js" index cbdb2e8..5bc020e 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex2.test.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex2.test.js" @@ -43,4 +43,4 @@ assert.deepStrictEqual( [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] ); -console.log(range(1, 2, 0.1)); +console.log(range(1, 2, 0.1)); \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex3.js" "b/\352\271\200\354\261\204\354\232\264/ex3.js" index b1b0d75..7729114 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex3.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex3.js" @@ -1,3 +1,41 @@ Array.prototype.sortBy = function (sortProp = '') { + const arr = []; + const props = sortProp.split(","); + + for(let p of props){ + arr.push(p.split(":")); + } + + for(let i = arr.length-1; i>=0; i--){ + if(arr[i].includes('name')){ + if(arr[i].includes('desc')){ + this.sort((a, b) => a.name > b.name ? -1 : 1); + }else{ + this.sort((a, b) => a.name < b.name ? -1 : 1); + } + } + else if(arr[i].includes('id')){ + if(arr[i].includes('desc')){ + this.sort((a, b) => a.id > b.id ? -1 : 1); + }else{ + this.sort((a, b) => a.id < b.id ? -1 : 1); + } + } + else if(arr[i].includes('city')){ + if(arr[i].includes('desc')){ + this.sort((a, b) => a.city > b.city ? -1 : 1); + }else{ + this.sort((a, b) => a.city < b.city ? -1 : 1); + } + } + else if(arr[i].includes('dept')){ + if(arr[i].includes('desc')){ + this.sort((a, b) => a.dept > b.dept ? -1 : 1); + }else{ + this.sort((a, b) => a.dept < b.dept ? -1 : 1); + } + } + } + return this; -}; +}; \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex3.test.js" "b/\352\271\200\354\261\204\354\232\264/ex3.test.js" index 6c27a4d..bc37804 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex3.test.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex3.test.js" @@ -8,11 +8,11 @@ const users = [lee, hong, kim]; assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); +assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [lee, kim, hong]); assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, lee, + kim, hong, ]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); +assert.deepStrictEqual(users.sortBy('dept:desc,id'), [kim, lee, hong]); \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex4.js" "b/\352\271\200\354\261\204\354\232\264/ex4.js" index 9ede02f..6613949 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex4.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex4.js" @@ -1,3 +1,56 @@ -function deepCopy(obj) {} +function deepCopy(obj) { + if (obj === null || typeof obj !== 'object') { + return obj; + } -module.exports = { deepCopy }; + if (obj instanceof Date) { + return new Date(obj.getTime()); + } + + if (obj instanceof RegExp) { + return new RegExp(obj); + } + + if (Array.isArray(obj)) { + return obj.map(item => deepCopy(item)); + } + + if (obj instanceof Set) { + const newSet = new Set(); + obj.forEach(value => { + newSet.add(deepCopy(value)); + }); + return newSet; + } + + if (obj instanceof Map) { + const newMap = new Map(); + obj.forEach((value, key) => { + newMap.set(deepCopy(key), deepCopy(value)); + }); + return newMap; + } + + if (obj instanceof WeakSet || obj instanceof WeakMap) { + return obj; + } + + const newObj = {}; + Object.keys(obj).forEach(key => { + newObj[key] = deepCopy(obj[key]); + }); + + const symbols = Object.getOwnPropertySymbols(obj); + symbols.forEach(symbol => { + newObj[symbol] = deepCopy(obj[symbol]); + }); + + const methods = Object.getOwnPropertyNames(obj).filter(key => typeof obj[key] === 'function'); + methods.forEach(key => { + newObj[key] = obj[key]; + }); + + return newObj; +} + +module.exports = { deepCopy }; \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex5.js" "b/\352\271\200\354\261\204\354\232\264/ex5.js" index 464a05a..2dfcf48 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex5.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex5.js" @@ -1,3 +1,30 @@ module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, + searchByKoreanInitialSound: (data, firstSounds) => { + const dataRegex = new RegExp(data); + const korean = ['ㄱ','ㄲ','ㄴ','ㄷ','ㄸ','ㄹ','ㅁ','ㅂ','ㅃ','ㅅ','ㅆ','ㅇ','ㅈ','ㅉ','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ']; + const 가 = '가'.charCodeAt(); //44032 + const first = Math.floor('까'.charCodeAt() - '가'.charCodeAt()); + const last = Math.floor('개'.charCodeAt() - '가'.charCodeAt()); + + const fs = firstSounds.split(""); + const regs = [] + + for(let i=0; i regex.test(item)) + }, }; + diff --git "a/\352\271\200\354\261\204\354\232\264/ex6.test.ts" "b/\352\271\200\354\261\204\354\232\264/ex6.test.ts" index 680c5e6..2385f9c 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex6.test.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex6.test.ts" @@ -1,5 +1,5 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; +import assert from "assert"; +import { promiseAllSettled, randTime } from "./ex6"; (async function testNormal() { assert.deepStrictEqual( @@ -12,12 +12,12 @@ import { promiseAllSettled, randTime } from './ex6'; assert.deepStrictEqual( await promiseAllSettled([ randTime(11), - Promise.reject('REJECT'), + Promise.reject("REJECT"), randTime(33), ]), await Promise.allSettled([ randTime(11), - Promise.reject('REJECT'), + Promise.reject("REJECT"), randTime(33), ]) ); diff --git "a/\352\271\200\354\261\204\354\232\264/ex6.ts" "b/\352\271\200\354\261\204\354\232\264/ex6.ts" index 424ca54..24ee373 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex6.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex6.ts" @@ -1,4 +1,43 @@ export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); + new Promise((resolve) => setTimeout(resolve, Math.random() * 1000, val)); -export function promiseAllSettled(promises: Promise[]) {} +export function promiseAll(promises: Promise[]): Promise { + const results: T[] = []; + let completed = 0; + let hasError = false; + let error: any = null; + + return new Promise((resolve, reject) => { + promises.forEach((promise, index) => { + promise + .then(value => { + if (hasError) return; + results[index] = value; + completed++; + if (completed === promises.length) { + resolve(results); + } + }) + .catch(err => { + if (hasError) return; + hasError = true; + error = err; + reject(error); + }); + }); + }); +} + +export function promiseAllSettled(promises: Promise[]): Promise> { + //성공 or 실패 상태를 반환하는 프로미스 배열 생성 + const wrappedPromises = promises.map(promise => + promise + .then( + value => ({ status: 'fulfilled', value }), + reason => ({ status: 'rejected', reason }) + ) + ); + + // 모든 프로미스가 완료될 때까지 기다리고 결과 반환 + return promiseAll(wrappedPromises) as Promise>; +} diff --git "a/\352\271\200\354\261\204\354\232\264/ex7.test.ts" "b/\352\271\200\354\261\204\354\232\264/ex7.test.ts" index 62b881d..d0bc5f2 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex7.test.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex7.test.ts" @@ -65,6 +65,13 @@ async function test(userId: string | number) { }); // 추가 테스트 코드를 작성하시오. + // 빈 결과를 반환할 때의 테스트 + const noPosts = await getPosts(99999); // 존재하지 않는 userId + assert.deepStrictEqual(noPosts, []); + + // 다른 userId에 대한 테스트 + const otherUserPosts = await getPosts(3); // 다른 userId + assert.strictEqual(otherUserPosts.length, 10); } test(1); diff --git "a/\352\271\200\354\261\204\354\232\264/ex7.ts" "b/\352\271\200\354\261\204\354\232\264/ex7.ts" index 62812ac..07c1f10 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex7.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex7.ts" @@ -1,3 +1,44 @@ const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; +const COMMENTS_URL = 'https://jsonplaceholder.typicode.com/comments'; -export async function getPosts(userId: number | string) {} +interface Comment { + postId: number; + id: number; + email: string; + body: string; + name?: string; +} + +interface Post { + postId: number; + title: string; + comments: Comment[]; +} + +async function fetchJson(url: string): Promise { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Failed to fetch: ${response.statusText}`); + } + return response.json() as Promise; +} + +export async function getPosts(userId: number | string): Promise { + //게시글 목록 받아오기 + const posts = await fetchJson<{ userId: number; id: number; title: string }[]>(`${POST_URL}?userId=${userId}`); + + const postsWithComments = await Promise.all( + posts.map(async (post) => { + // 댓글url + const comments = await fetchJson(`${COMMENTS_URL}?postId=${post.id}`); + return { + postId: post.id, + title: post.title, + comments: comments.map(({ name, ...comment }) => comment) // name 필드를 제거하거나 필요한 데이터만 반환 + }; + }) + ); + + return postsWithComments; + } + \ No newline at end of file diff --git "a/\352\271\200\354\261\204\354\232\264/ex8.ts" "b/\352\271\200\354\261\204\354\232\264/ex8.ts" index a67a2d2..32c46c2 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex8.ts" +++ "b/\352\271\200\354\261\204\354\232\264/ex8.ts" @@ -1,8 +1,25 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... +const debounce = (cb: (i: number) => void, delay: number) => { + let timeoutId: NodeJS.Timeout | null = null; + + return (i: number) => { + if (timeoutId) { + clearTimeout(timeoutId); + } + timeoutId = setTimeout(() => cb(i), delay); + }; + }; + + const throttle = (cb: (i: number) => void, delay: number) => { + let lastExecuted = 0; + + return (i: number) => { + const now = Date.now(); + if (now - lastExecuted >= delay) { + lastExecuted = now; + cb(i); + } + }; + }; const debo = debounce((a: number) => console.log(a + 1), 500); for (let i = 10; i < 15; i++) debo(i); // 15 출력 diff --git "a/\352\271\200\354\261\204\354\232\264/ex9.js" "b/\352\271\200\354\261\204\354\232\264/ex9.js" index ec3044f..983bc2f 100644 --- "a/\352\271\200\354\261\204\354\232\264/ex9.js" +++ "b/\352\271\200\354\261\204\354\232\264/ex9.js" @@ -24,10 +24,10 @@ function bill(tableNo) { printLine(); for (const item of ordered) { const { price, taxfree } = MENU[item]; - console.log('*', item); + console.log("*", item); f`공급가액: ${price}원`; f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); + printLine("-"); } f`주문합계: ${tot.price}원`; f`주문합계: ${tot.tax}원`; @@ -37,29 +37,29 @@ function bill(tableNo) { } const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); +table1.order("짜장"); +table1.order("짬뽕"); table1.printBill(); const table2 = bill(2); -table2.order('짜장'); +table2.order("짜장"); table2.printBill(); -table1.order('탕슉'); +table1.order("탕슉"); table1.printBill(); -table2.order('짬뽕'); +table2.order("짬뽕"); table2.printBill(); function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); + console.log(`${label.padEnd(LABEL_SIZE, " ")} ${priceFmt(price)}`); } -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; +function priceFmt(price, unit = "원") { + return price.toLocaleString().padStart(PRICE_SIZE, " ") + unit; } -function printLine(flag = '=') { +function printLine(flag = "=") { console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); } diff --git "a/\352\271\200\354\261\204\354\232\264/test.ts" "b/\352\271\200\354\261\204\354\232\264/test.ts" new file mode 100644 index 0000000..a00b99d --- /dev/null +++ "b/\352\271\200\354\261\204\354\232\264/test.ts" @@ -0,0 +1,2 @@ +let test: string = "hello worlddd"; +console.log(test); diff --git "a/\352\271\200\355\225\264\354\233\220/ex1/book-edit.html" "b/\352\271\200\355\225\264\354\233\220/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\355\225\264\354\233\220/ex1/index.html" "b/\352\271\200\355\225\264\354\233\220/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\355\225\264\354\233\220/ex1/register.html" "b/\352\271\200\355\225\264\354\233\220/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\352\271\200\355\225\264\354\233\220/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\352\271\200\355\225\264\354\233\220/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\352\271\200\355\225\264\354\233\220/ex10.test.ts" "b/\352\271\200\355\225\264\354\233\220/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\352\271\200\355\225\264\354\233\220/ex10.ts" "b/\352\271\200\355\225\264\354\233\220/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\352\271\200\355\225\264\354\233\220/ex2.js" "b/\352\271\200\355\225\264\354\233\220/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\352\271\200\355\225\264\354\233\220/ex2.test.js" "b/\352\271\200\355\225\264\354\233\220/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\352\271\200\355\225\264\354\233\220/ex3.js" "b/\352\271\200\355\225\264\354\233\220/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\352\271\200\355\225\264\354\233\220/ex3.test.js" "b/\352\271\200\355\225\264\354\233\220/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\352\271\200\355\225\264\354\233\220/ex4.js" "b/\352\271\200\355\225\264\354\233\220/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\352\271\200\355\225\264\354\233\220/ex4.test.js" "b/\352\271\200\355\225\264\354\233\220/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\352\271\200\355\225\264\354\233\220/ex5.js" "b/\352\271\200\355\225\264\354\233\220/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\352\271\200\355\225\264\354\233\220/ex5.test.js" "b/\352\271\200\355\225\264\354\233\220/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\352\271\200\355\225\264\354\233\220/ex6.test.ts" "b/\352\271\200\355\225\264\354\233\220/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\352\271\200\355\225\264\354\233\220/ex6.ts" "b/\352\271\200\355\225\264\354\233\220/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\352\271\200\355\225\264\354\233\220/ex7.test.ts" "b/\352\271\200\355\225\264\354\233\220/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\352\271\200\355\225\264\354\233\220/ex7.ts" "b/\352\271\200\355\225\264\354\233\220/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\352\271\200\355\225\264\354\233\220/ex8.ts" "b/\352\271\200\355\225\264\354\233\220/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\352\271\200\355\225\264\354\233\220/ex9.js" "b/\352\271\200\355\225\264\354\233\220/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\352\271\200\355\225\264\354\233\220/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\353\260\225\354\213\234\355\231\215/ex1/book-edit.html" "b/\353\260\225\354\213\234\355\231\215/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\213\234\355\231\215/ex1/index.html" "b/\353\260\225\354\213\234\355\231\215/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\213\234\355\231\215/ex1/register.html" "b/\353\260\225\354\213\234\355\231\215/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\213\234\355\231\215/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\353\260\225\354\213\234\355\231\215/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\353\260\225\354\213\234\355\231\215/ex10.test.ts" "b/\353\260\225\354\213\234\355\231\215/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\353\260\225\354\213\234\355\231\215/ex10.ts" "b/\353\260\225\354\213\234\355\231\215/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\353\260\225\354\213\234\355\231\215/ex2.js" "b/\353\260\225\354\213\234\355\231\215/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\353\260\225\354\213\234\355\231\215/ex2.test.js" "b/\353\260\225\354\213\234\355\231\215/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\353\260\225\354\213\234\355\231\215/ex3.js" "b/\353\260\225\354\213\234\355\231\215/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\353\260\225\354\213\234\355\231\215/ex3.test.js" "b/\353\260\225\354\213\234\355\231\215/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\353\260\225\354\213\234\355\231\215/ex4.js" "b/\353\260\225\354\213\234\355\231\215/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\353\260\225\354\213\234\355\231\215/ex4.test.js" "b/\353\260\225\354\213\234\355\231\215/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\353\260\225\354\213\234\355\231\215/ex5.js" "b/\353\260\225\354\213\234\355\231\215/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\353\260\225\354\213\234\355\231\215/ex5.test.js" "b/\353\260\225\354\213\234\355\231\215/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\353\260\225\354\213\234\355\231\215/ex6.test.ts" "b/\353\260\225\354\213\234\355\231\215/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\353\260\225\354\213\234\355\231\215/ex6.ts" "b/\353\260\225\354\213\234\355\231\215/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\353\260\225\354\213\234\355\231\215/ex7.test.ts" "b/\353\260\225\354\213\234\355\231\215/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\353\260\225\354\213\234\355\231\215/ex7.ts" "b/\353\260\225\354\213\234\355\231\215/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\353\260\225\354\213\234\355\231\215/ex8.ts" "b/\353\260\225\354\213\234\355\231\215/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\353\260\225\354\213\234\355\231\215/ex9.js" "b/\353\260\225\354\213\234\355\231\215/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\353\260\225\354\213\234\355\231\215/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\353\260\225\354\247\200\355\231\230/ex1/book-edit.html" "b/\353\260\225\354\247\200\355\231\230/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\247\200\355\231\230/ex1/index.html" "b/\353\260\225\354\247\200\355\231\230/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\247\200\355\231\230/ex1/register.html" "b/\353\260\225\354\247\200\355\231\230/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\247\200\355\231\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\353\260\225\354\247\200\355\231\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\353\260\225\354\247\200\355\231\230/ex10.test.ts" "b/\353\260\225\354\247\200\355\231\230/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\353\260\225\354\247\200\355\231\230/ex10.ts" "b/\353\260\225\354\247\200\355\231\230/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\353\260\225\354\247\200\355\231\230/ex2.js" "b/\353\260\225\354\247\200\355\231\230/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\353\260\225\354\247\200\355\231\230/ex2.test.js" "b/\353\260\225\354\247\200\355\231\230/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\353\260\225\354\247\200\355\231\230/ex3.js" "b/\353\260\225\354\247\200\355\231\230/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\353\260\225\354\247\200\355\231\230/ex3.test.js" "b/\353\260\225\354\247\200\355\231\230/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\353\260\225\354\247\200\355\231\230/ex4.js" "b/\353\260\225\354\247\200\355\231\230/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\353\260\225\354\247\200\355\231\230/ex4.test.js" "b/\353\260\225\354\247\200\355\231\230/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\353\260\225\354\247\200\355\231\230/ex5.js" "b/\353\260\225\354\247\200\355\231\230/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\353\260\225\354\247\200\355\231\230/ex5.test.js" "b/\353\260\225\354\247\200\355\231\230/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\353\260\225\354\247\200\355\231\230/ex6.test.ts" "b/\353\260\225\354\247\200\355\231\230/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\353\260\225\354\247\200\355\231\230/ex6.ts" "b/\353\260\225\354\247\200\355\231\230/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\353\260\225\354\247\200\355\231\230/ex7.test.ts" "b/\353\260\225\354\247\200\355\231\230/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\353\260\225\354\247\200\355\231\230/ex7.ts" "b/\353\260\225\354\247\200\355\231\230/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\353\260\225\354\247\200\355\231\230/ex8.ts" "b/\353\260\225\354\247\200\355\231\230/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\353\260\225\354\247\200\355\231\230/ex9.js" "b/\353\260\225\354\247\200\355\231\230/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\353\260\225\354\247\200\355\231\230/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\353\260\225\354\261\204\353\246\260/ex1/book-edit.html" "b/\353\260\225\354\261\204\353\246\260/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\261\204\353\246\260/ex1/index.html" "b/\353\260\225\354\261\204\353\246\260/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\261\204\353\246\260/ex1/register.html" "b/\353\260\225\354\261\204\353\246\260/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\353\260\225\354\261\204\353\246\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\353\260\225\354\261\204\353\246\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\353\260\225\354\261\204\353\246\260/ex10.test.ts" "b/\353\260\225\354\261\204\353\246\260/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\353\260\225\354\261\204\353\246\260/ex10.ts" "b/\353\260\225\354\261\204\353\246\260/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\353\260\225\354\261\204\353\246\260/ex2.js" "b/\353\260\225\354\261\204\353\246\260/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\353\260\225\354\261\204\353\246\260/ex2.test.js" "b/\353\260\225\354\261\204\353\246\260/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\353\260\225\354\261\204\353\246\260/ex3.js" "b/\353\260\225\354\261\204\353\246\260/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\353\260\225\354\261\204\353\246\260/ex3.test.js" "b/\353\260\225\354\261\204\353\246\260/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\353\260\225\354\261\204\353\246\260/ex4.js" "b/\353\260\225\354\261\204\353\246\260/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\353\260\225\354\261\204\353\246\260/ex4.test.js" "b/\353\260\225\354\261\204\353\246\260/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\353\260\225\354\261\204\353\246\260/ex5.js" "b/\353\260\225\354\261\204\353\246\260/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\353\260\225\354\261\204\353\246\260/ex5.test.js" "b/\353\260\225\354\261\204\353\246\260/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\353\260\225\354\261\204\353\246\260/ex6.test.ts" "b/\353\260\225\354\261\204\353\246\260/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\353\260\225\354\261\204\353\246\260/ex6.ts" "b/\353\260\225\354\261\204\353\246\260/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\353\260\225\354\261\204\353\246\260/ex7.test.ts" "b/\353\260\225\354\261\204\353\246\260/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\353\260\225\354\261\204\353\246\260/ex7.ts" "b/\353\260\225\354\261\204\353\246\260/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\353\260\225\354\261\204\353\246\260/ex8.ts" "b/\353\260\225\354\261\204\353\246\260/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\353\260\225\354\261\204\353\246\260/ex9.js" "b/\353\260\225\354\261\204\353\246\260/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\353\260\225\354\261\204\353\246\260/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\226\221\354\247\200\354\235\200/ex1/book-edit.html" "b/\354\226\221\354\247\200\354\235\200/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\226\221\354\247\200\354\235\200/ex1/index.html" "b/\354\226\221\354\247\200\354\235\200/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\226\221\354\247\200\354\235\200/ex1/register.html" "b/\354\226\221\354\247\200\354\235\200/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\226\221\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\226\221\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\226\221\354\247\200\354\235\200/ex10.test.ts" "b/\354\226\221\354\247\200\354\235\200/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\226\221\354\247\200\354\235\200/ex10.ts" "b/\354\226\221\354\247\200\354\235\200/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\226\221\354\247\200\354\235\200/ex2.js" "b/\354\226\221\354\247\200\354\235\200/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\226\221\354\247\200\354\235\200/ex2.test.js" "b/\354\226\221\354\247\200\354\235\200/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\226\221\354\247\200\354\235\200/ex3.js" "b/\354\226\221\354\247\200\354\235\200/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\226\221\354\247\200\354\235\200/ex3.test.js" "b/\354\226\221\354\247\200\354\235\200/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\226\221\354\247\200\354\235\200/ex4.js" "b/\354\226\221\354\247\200\354\235\200/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\226\221\354\247\200\354\235\200/ex4.test.js" "b/\354\226\221\354\247\200\354\235\200/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\226\221\354\247\200\354\235\200/ex5.js" "b/\354\226\221\354\247\200\354\235\200/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\226\221\354\247\200\354\235\200/ex5.test.js" "b/\354\226\221\354\247\200\354\235\200/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\226\221\354\247\200\354\235\200/ex6.test.ts" "b/\354\226\221\354\247\200\354\235\200/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\226\221\354\247\200\354\235\200/ex6.ts" "b/\354\226\221\354\247\200\354\235\200/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\226\221\354\247\200\354\235\200/ex7.test.ts" "b/\354\226\221\354\247\200\354\235\200/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\226\221\354\247\200\354\235\200/ex7.ts" "b/\354\226\221\354\247\200\354\235\200/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\226\221\354\247\200\354\235\200/ex8.ts" "b/\354\226\221\354\247\200\354\235\200/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\226\221\354\247\200\354\235\200/ex9.js" "b/\354\226\221\354\247\200\354\235\200/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\226\221\354\247\200\354\235\200/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\234\240\354\234\240\354\240\225/ex1/book-edit.html" "b/\354\234\240\354\234\240\354\240\225/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\240\354\234\240\354\240\225/ex1/index.html" "b/\354\234\240\354\234\240\354\240\225/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\240\354\234\240\354\240\225/ex1/register.html" "b/\354\234\240\354\234\240\354\240\225/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\240\354\234\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\234\240\354\234\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\234\240\354\234\240\354\240\225/ex10.test.ts" "b/\354\234\240\354\234\240\354\240\225/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\234\240\354\234\240\354\240\225/ex10.ts" "b/\354\234\240\354\234\240\354\240\225/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\234\240\354\234\240\354\240\225/ex2.js" "b/\354\234\240\354\234\240\354\240\225/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\234\240\354\234\240\354\240\225/ex2.test.js" "b/\354\234\240\354\234\240\354\240\225/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\234\240\354\234\240\354\240\225/ex3.js" "b/\354\234\240\354\234\240\354\240\225/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\234\240\354\234\240\354\240\225/ex3.test.js" "b/\354\234\240\354\234\240\354\240\225/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\234\240\354\234\240\354\240\225/ex4.js" "b/\354\234\240\354\234\240\354\240\225/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\234\240\354\234\240\354\240\225/ex4.test.js" "b/\354\234\240\354\234\240\354\240\225/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\234\240\354\234\240\354\240\225/ex5.js" "b/\354\234\240\354\234\240\354\240\225/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\234\240\354\234\240\354\240\225/ex5.test.js" "b/\354\234\240\354\234\240\354\240\225/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\234\240\354\234\240\354\240\225/ex6.test.ts" "b/\354\234\240\354\234\240\354\240\225/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\234\240\354\234\240\354\240\225/ex6.ts" "b/\354\234\240\354\234\240\354\240\225/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\234\240\354\234\240\354\240\225/ex7.test.ts" "b/\354\234\240\354\234\240\354\240\225/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\234\240\354\234\240\354\240\225/ex7.ts" "b/\354\234\240\354\234\240\354\240\225/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\234\240\354\234\240\354\240\225/ex8.ts" "b/\354\234\240\354\234\240\354\240\225/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\234\240\354\234\240\354\240\225/ex9.js" "b/\354\234\240\354\234\240\354\240\225/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\234\240\354\234\240\354\240\225/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\234\241\354\247\200\354\235\200/ex1/book-edit.html" "b/\354\234\241\354\247\200\354\235\200/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\241\354\247\200\354\235\200/ex1/index.html" "b/\354\234\241\354\247\200\354\235\200/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\241\354\247\200\354\235\200/ex1/register.html" "b/\354\234\241\354\247\200\354\235\200/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\241\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\234\241\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\234\241\354\247\200\354\235\200/ex10.test.ts" "b/\354\234\241\354\247\200\354\235\200/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\234\241\354\247\200\354\235\200/ex10.ts" "b/\354\234\241\354\247\200\354\235\200/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\234\241\354\247\200\354\235\200/ex2.js" "b/\354\234\241\354\247\200\354\235\200/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\234\241\354\247\200\354\235\200/ex2.test.js" "b/\354\234\241\354\247\200\354\235\200/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\234\241\354\247\200\354\235\200/ex3.js" "b/\354\234\241\354\247\200\354\235\200/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\234\241\354\247\200\354\235\200/ex3.test.js" "b/\354\234\241\354\247\200\354\235\200/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\234\241\354\247\200\354\235\200/ex4.js" "b/\354\234\241\354\247\200\354\235\200/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\234\241\354\247\200\354\235\200/ex4.test.js" "b/\354\234\241\354\247\200\354\235\200/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\234\241\354\247\200\354\235\200/ex5.js" "b/\354\234\241\354\247\200\354\235\200/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\234\241\354\247\200\354\235\200/ex5.test.js" "b/\354\234\241\354\247\200\354\235\200/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\234\241\354\247\200\354\235\200/ex6.test.ts" "b/\354\234\241\354\247\200\354\235\200/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\234\241\354\247\200\354\235\200/ex6.ts" "b/\354\234\241\354\247\200\354\235\200/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\234\241\354\247\200\354\235\200/ex7.test.ts" "b/\354\234\241\354\247\200\354\235\200/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\234\241\354\247\200\354\235\200/ex7.ts" "b/\354\234\241\354\247\200\354\235\200/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\234\241\354\247\200\354\235\200/ex8.ts" "b/\354\234\241\354\247\200\354\235\200/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\234\241\354\247\200\354\235\200/ex9.js" "b/\354\234\241\354\247\200\354\235\200/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\234\241\354\247\200\354\235\200/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\234\244\352\261\264\355\235\254/ex1/book-edit.html" "b/\354\234\244\352\261\264\355\235\254/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\352\261\264\355\235\254/ex1/index.html" "b/\354\234\244\352\261\264\355\235\254/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\352\261\264\355\235\254/ex1/register.html" "b/\354\234\244\352\261\264\355\235\254/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\352\261\264\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\234\244\352\261\264\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\234\244\352\261\264\355\235\254/ex10.test.ts" "b/\354\234\244\352\261\264\355\235\254/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\234\244\352\261\264\355\235\254/ex10.ts" "b/\354\234\244\352\261\264\355\235\254/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\234\244\352\261\264\355\235\254/ex2.js" "b/\354\234\244\352\261\264\355\235\254/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\234\244\352\261\264\355\235\254/ex2.test.js" "b/\354\234\244\352\261\264\355\235\254/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\234\244\352\261\264\355\235\254/ex3.js" "b/\354\234\244\352\261\264\355\235\254/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\234\244\352\261\264\355\235\254/ex3.test.js" "b/\354\234\244\352\261\264\355\235\254/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\234\244\352\261\264\355\235\254/ex4.js" "b/\354\234\244\352\261\264\355\235\254/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\234\244\352\261\264\355\235\254/ex4.test.js" "b/\354\234\244\352\261\264\355\235\254/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\234\244\352\261\264\355\235\254/ex5.js" "b/\354\234\244\352\261\264\355\235\254/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\234\244\352\261\264\355\235\254/ex5.test.js" "b/\354\234\244\352\261\264\355\235\254/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\234\244\352\261\264\355\235\254/ex6.test.ts" "b/\354\234\244\352\261\264\355\235\254/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\234\244\352\261\264\355\235\254/ex6.ts" "b/\354\234\244\352\261\264\355\235\254/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\234\244\352\261\264\355\235\254/ex7.test.ts" "b/\354\234\244\352\261\264\355\235\254/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\234\244\352\261\264\355\235\254/ex7.ts" "b/\354\234\244\352\261\264\355\235\254/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\234\244\352\261\264\355\235\254/ex8.ts" "b/\354\234\244\352\261\264\355\235\254/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\234\244\352\261\264\355\235\254/ex9.js" "b/\354\234\244\352\261\264\355\235\254/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\234\244\352\261\264\355\235\254/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\234\244\354\230\201\355\227\214/ex1/book-edit.html" "b/\354\234\244\354\230\201\355\227\214/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\354\230\201\355\227\214/ex1/index.html" "b/\354\234\244\354\230\201\355\227\214/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\354\230\201\355\227\214/ex1/register.html" "b/\354\234\244\354\230\201\355\227\214/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\234\244\354\230\201\355\227\214/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\234\244\354\230\201\355\227\214/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\234\244\354\230\201\355\227\214/ex10.test.ts" "b/\354\234\244\354\230\201\355\227\214/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\234\244\354\230\201\355\227\214/ex10.ts" "b/\354\234\244\354\230\201\355\227\214/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\234\244\354\230\201\355\227\214/ex2.js" "b/\354\234\244\354\230\201\355\227\214/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\234\244\354\230\201\355\227\214/ex2.test.js" "b/\354\234\244\354\230\201\355\227\214/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\234\244\354\230\201\355\227\214/ex3.js" "b/\354\234\244\354\230\201\355\227\214/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\234\244\354\230\201\355\227\214/ex3.test.js" "b/\354\234\244\354\230\201\355\227\214/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\234\244\354\230\201\355\227\214/ex4.js" "b/\354\234\244\354\230\201\355\227\214/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\234\244\354\230\201\355\227\214/ex4.test.js" "b/\354\234\244\354\230\201\355\227\214/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\234\244\354\230\201\355\227\214/ex5.js" "b/\354\234\244\354\230\201\355\227\214/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\234\244\354\230\201\355\227\214/ex5.test.js" "b/\354\234\244\354\230\201\355\227\214/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\234\244\354\230\201\355\227\214/ex6.test.ts" "b/\354\234\244\354\230\201\355\227\214/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\234\244\354\230\201\355\227\214/ex6.ts" "b/\354\234\244\354\230\201\355\227\214/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\234\244\354\230\201\355\227\214/ex7.test.ts" "b/\354\234\244\354\230\201\355\227\214/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\234\244\354\230\201\355\227\214/ex7.ts" "b/\354\234\244\354\230\201\355\227\214/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\234\244\354\230\201\355\227\214/ex8.ts" "b/\354\234\244\354\230\201\355\227\214/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\234\244\354\230\201\355\227\214/ex9.js" "b/\354\234\244\354\230\201\355\227\214/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\234\244\354\230\201\355\227\214/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\235\264\353\217\231\354\234\244/ex1/book-edit.html" "b/\354\235\264\353\217\231\354\234\244/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\353\217\231\354\234\244/ex1/index.html" "b/\354\235\264\353\217\231\354\234\244/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\353\217\231\354\234\244/ex1/register.html" "b/\354\235\264\353\217\231\354\234\244/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\353\217\231\354\234\244/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\235\264\353\217\231\354\234\244/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\235\264\353\217\231\354\234\244/ex10.test.ts" "b/\354\235\264\353\217\231\354\234\244/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\235\264\353\217\231\354\234\244/ex10.ts" "b/\354\235\264\353\217\231\354\234\244/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\235\264\353\217\231\354\234\244/ex2.js" "b/\354\235\264\353\217\231\354\234\244/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\235\264\353\217\231\354\234\244/ex2.test.js" "b/\354\235\264\353\217\231\354\234\244/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\235\264\353\217\231\354\234\244/ex3.js" "b/\354\235\264\353\217\231\354\234\244/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\235\264\353\217\231\354\234\244/ex3.test.js" "b/\354\235\264\353\217\231\354\234\244/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\235\264\353\217\231\354\234\244/ex4.js" "b/\354\235\264\353\217\231\354\234\244/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\235\264\353\217\231\354\234\244/ex4.test.js" "b/\354\235\264\353\217\231\354\234\244/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\235\264\353\217\231\354\234\244/ex5.js" "b/\354\235\264\353\217\231\354\234\244/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\235\264\353\217\231\354\234\244/ex5.test.js" "b/\354\235\264\353\217\231\354\234\244/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\235\264\353\217\231\354\234\244/ex6.test.ts" "b/\354\235\264\353\217\231\354\234\244/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\235\264\353\217\231\354\234\244/ex6.ts" "b/\354\235\264\353\217\231\354\234\244/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\235\264\353\217\231\354\234\244/ex7.test.ts" "b/\354\235\264\353\217\231\354\234\244/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\235\264\353\217\231\354\234\244/ex7.ts" "b/\354\235\264\353\217\231\354\234\244/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\235\264\353\217\231\354\234\244/ex8.ts" "b/\354\235\264\353\217\231\354\234\244/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\235\264\353\217\231\354\234\244/ex9.js" "b/\354\235\264\353\217\231\354\234\244/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\235\264\353\217\231\354\234\244/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" "b/\354\235\264\354\210\230\353\257\274/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/index.html" "b/\354\235\264\354\210\230\353\257\274/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/register.html" "b/\354\235\264\354\210\230\353\257\274/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\210\230\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\235\264\354\210\230\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\235\264\354\210\230\353\257\274/ex10.test.ts" "b/\354\235\264\354\210\230\353\257\274/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\235\264\354\210\230\353\257\274/ex10.ts" "b/\354\235\264\354\210\230\353\257\274/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex2.js" "b/\354\235\264\354\210\230\353\257\274/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex2.test.js" "b/\354\235\264\354\210\230\353\257\274/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.js" "b/\354\235\264\354\210\230\353\257\274/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" "b/\354\235\264\354\210\230\353\257\274/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\235\264\354\210\230\353\257\274/ex4.js" "b/\354\235\264\354\210\230\353\257\274/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\235\264\354\210\230\353\257\274/ex4.test.js" "b/\354\235\264\354\210\230\353\257\274/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\235\264\354\210\230\353\257\274/ex5.js" "b/\354\235\264\354\210\230\353\257\274/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\235\264\354\210\230\353\257\274/ex5.test.js" "b/\354\235\264\354\210\230\353\257\274/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\235\264\354\210\230\353\257\274/ex6.test.ts" "b/\354\235\264\354\210\230\353\257\274/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\235\264\354\210\230\353\257\274/ex6.ts" "b/\354\235\264\354\210\230\353\257\274/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\235\264\354\210\230\353\257\274/ex7.test.ts" "b/\354\235\264\354\210\230\353\257\274/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\235\264\354\210\230\353\257\274/ex7.ts" "b/\354\235\264\354\210\230\353\257\274/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\235\264\354\210\230\353\257\274/ex8.ts" "b/\354\235\264\354\210\230\353\257\274/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\235\264\354\210\230\353\257\274/ex9.js" "b/\354\235\264\354\210\230\353\257\274/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\235\264\354\210\230\353\257\274/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\235\264\354\235\270\354\210\230/ex1/book-edit.html" "b/\354\235\264\354\235\270\354\210\230/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\235\270\354\210\230/ex1/index.html" "b/\354\235\264\354\235\270\354\210\230/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\235\270\354\210\230/ex1/register.html" "b/\354\235\264\354\235\270\354\210\230/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\354\235\270\354\210\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\235\264\354\235\270\354\210\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\235\264\354\235\270\354\210\230/ex10.test.ts" "b/\354\235\264\354\235\270\354\210\230/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\235\264\354\235\270\354\210\230/ex10.ts" "b/\354\235\264\354\235\270\354\210\230/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\235\264\354\235\270\354\210\230/ex2.js" "b/\354\235\264\354\235\270\354\210\230/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\235\264\354\235\270\354\210\230/ex2.test.js" "b/\354\235\264\354\235\270\354\210\230/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\235\264\354\235\270\354\210\230/ex3.js" "b/\354\235\264\354\235\270\354\210\230/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\235\264\354\235\270\354\210\230/ex3.test.js" "b/\354\235\264\354\235\270\354\210\230/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\235\264\354\235\270\354\210\230/ex4.js" "b/\354\235\264\354\235\270\354\210\230/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\235\264\354\235\270\354\210\230/ex4.test.js" "b/\354\235\264\354\235\270\354\210\230/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\235\264\354\235\270\354\210\230/ex5.js" "b/\354\235\264\354\235\270\354\210\230/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\235\264\354\235\270\354\210\230/ex5.test.js" "b/\354\235\264\354\235\270\354\210\230/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\235\264\354\235\270\354\210\230/ex6.test.ts" "b/\354\235\264\354\235\270\354\210\230/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\235\264\354\235\270\354\210\230/ex6.ts" "b/\354\235\264\354\235\270\354\210\230/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\235\264\354\235\270\354\210\230/ex7.test.ts" "b/\354\235\264\354\235\270\354\210\230/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\235\264\354\235\270\354\210\230/ex7.ts" "b/\354\235\264\354\235\270\354\210\230/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\235\264\354\235\270\354\210\230/ex8.ts" "b/\354\235\264\354\235\270\354\210\230/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\235\264\354\235\270\354\210\230/ex9.js" "b/\354\235\264\354\235\270\354\210\230/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\235\264\354\235\270\354\210\230/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\235\264\355\225\230\353\212\230/ex1/book-edit.html" "b/\354\235\264\355\225\230\353\212\230/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\355\225\230\353\212\230/ex1/index.html" "b/\354\235\264\355\225\230\353\212\230/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\355\225\230\353\212\230/ex1/register.html" "b/\354\235\264\355\225\230\353\212\230/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\235\264\355\225\230\353\212\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\235\264\355\225\230\353\212\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\235\264\355\225\230\353\212\230/ex10.test.ts" "b/\354\235\264\355\225\230\353\212\230/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\235\264\355\225\230\353\212\230/ex10.ts" "b/\354\235\264\355\225\230\353\212\230/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\235\264\355\225\230\353\212\230/ex2.js" "b/\354\235\264\355\225\230\353\212\230/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\235\264\355\225\230\353\212\230/ex2.test.js" "b/\354\235\264\355\225\230\353\212\230/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\235\264\355\225\230\353\212\230/ex3.js" "b/\354\235\264\355\225\230\353\212\230/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\235\264\355\225\230\353\212\230/ex3.test.js" "b/\354\235\264\355\225\230\353\212\230/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\235\264\355\225\230\353\212\230/ex4.js" "b/\354\235\264\355\225\230\353\212\230/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\235\264\355\225\230\353\212\230/ex4.test.js" "b/\354\235\264\355\225\230\353\212\230/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\235\264\355\225\230\353\212\230/ex5.js" "b/\354\235\264\355\225\230\353\212\230/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\235\264\355\225\230\353\212\230/ex5.test.js" "b/\354\235\264\355\225\230\353\212\230/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\235\264\355\225\230\353\212\230/ex6.test.ts" "b/\354\235\264\355\225\230\353\212\230/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\235\264\355\225\230\353\212\230/ex6.ts" "b/\354\235\264\355\225\230\353\212\230/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\235\264\355\225\230\353\212\230/ex7.test.ts" "b/\354\235\264\355\225\230\353\212\230/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\235\264\355\225\230\353\212\230/ex7.ts" "b/\354\235\264\355\225\230\353\212\230/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\235\264\355\225\230\353\212\230/ex8.ts" "b/\354\235\264\355\225\230\353\212\230/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\235\264\355\225\230\353\212\230/ex9.js" "b/\354\235\264\355\225\230\353\212\230/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\235\264\355\225\230\353\212\230/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\236\204\354\210\230\354\247\204/ex1/book-edit.html" "b/\354\236\204\354\210\230\354\247\204/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\236\204\354\210\230\354\247\204/ex1/index.html" "b/\354\236\204\354\210\230\354\247\204/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\236\204\354\210\230\354\247\204/ex1/register.html" "b/\354\236\204\354\210\230\354\247\204/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\236\204\354\210\230\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\236\204\354\210\230\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\236\204\354\210\230\354\247\204/ex10.test.ts" "b/\354\236\204\354\210\230\354\247\204/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\236\204\354\210\230\354\247\204/ex10.ts" "b/\354\236\204\354\210\230\354\247\204/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\236\204\354\210\230\354\247\204/ex2.js" "b/\354\236\204\354\210\230\354\247\204/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\236\204\354\210\230\354\247\204/ex2.test.js" "b/\354\236\204\354\210\230\354\247\204/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\236\204\354\210\230\354\247\204/ex3.js" "b/\354\236\204\354\210\230\354\247\204/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\236\204\354\210\230\354\247\204/ex3.test.js" "b/\354\236\204\354\210\230\354\247\204/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\236\204\354\210\230\354\247\204/ex4.js" "b/\354\236\204\354\210\230\354\247\204/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\236\204\354\210\230\354\247\204/ex4.test.js" "b/\354\236\204\354\210\230\354\247\204/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\236\204\354\210\230\354\247\204/ex5.js" "b/\354\236\204\354\210\230\354\247\204/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\236\204\354\210\230\354\247\204/ex5.test.js" "b/\354\236\204\354\210\230\354\247\204/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\236\204\354\210\230\354\247\204/ex6.test.ts" "b/\354\236\204\354\210\230\354\247\204/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\236\204\354\210\230\354\247\204/ex6.ts" "b/\354\236\204\354\210\230\354\247\204/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\236\204\354\210\230\354\247\204/ex7.test.ts" "b/\354\236\204\354\210\230\354\247\204/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\236\204\354\210\230\354\247\204/ex7.ts" "b/\354\236\204\354\210\230\354\247\204/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\236\204\354\210\230\354\247\204/ex8.ts" "b/\354\236\204\354\210\230\354\247\204/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\236\204\354\210\230\354\247\204/ex9.js" "b/\354\236\204\354\210\230\354\247\204/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\236\204\354\210\230\354\247\204/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\240\225\354\212\271\354\232\251/ex1/book-edit.html" "b/\354\240\225\354\212\271\354\232\251/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\212\271\354\232\251/ex1/index.html" "b/\354\240\225\354\212\271\354\232\251/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\212\271\354\232\251/ex1/register.html" "b/\354\240\225\354\212\271\354\232\251/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\212\271\354\232\251/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\240\225\354\212\271\354\232\251/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\240\225\354\212\271\354\232\251/ex10.test.ts" "b/\354\240\225\354\212\271\354\232\251/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\240\225\354\212\271\354\232\251/ex10.ts" "b/\354\240\225\354\212\271\354\232\251/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\240\225\354\212\271\354\232\251/ex2.js" "b/\354\240\225\354\212\271\354\232\251/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\240\225\354\212\271\354\232\251/ex2.test.js" "b/\354\240\225\354\212\271\354\232\251/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\240\225\354\212\271\354\232\251/ex3.js" "b/\354\240\225\354\212\271\354\232\251/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\240\225\354\212\271\354\232\251/ex3.test.js" "b/\354\240\225\354\212\271\354\232\251/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\240\225\354\212\271\354\232\251/ex4.js" "b/\354\240\225\354\212\271\354\232\251/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\240\225\354\212\271\354\232\251/ex4.test.js" "b/\354\240\225\354\212\271\354\232\251/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\240\225\354\212\271\354\232\251/ex5.js" "b/\354\240\225\354\212\271\354\232\251/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\240\225\354\212\271\354\232\251/ex5.test.js" "b/\354\240\225\354\212\271\354\232\251/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\240\225\354\212\271\354\232\251/ex6.test.ts" "b/\354\240\225\354\212\271\354\232\251/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\240\225\354\212\271\354\232\251/ex6.ts" "b/\354\240\225\354\212\271\354\232\251/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\240\225\354\212\271\354\232\251/ex7.test.ts" "b/\354\240\225\354\212\271\354\232\251/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\240\225\354\212\271\354\232\251/ex7.ts" "b/\354\240\225\354\212\271\354\232\251/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\240\225\354\212\271\354\232\251/ex8.ts" "b/\354\240\225\354\212\271\354\232\251/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\240\225\354\212\271\354\232\251/ex9.js" "b/\354\240\225\354\212\271\354\232\251/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\240\225\354\212\271\354\232\251/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\240\225\354\227\260\354\261\204/ex1/book-edit.html" "b/\354\240\225\354\227\260\354\261\204/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\227\260\354\261\204/ex1/index.html" "b/\354\240\225\354\227\260\354\261\204/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\227\260\354\261\204/ex1/register.html" "b/\354\240\225\354\227\260\354\261\204/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\227\260\354\261\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\240\225\354\227\260\354\261\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\240\225\354\227\260\354\261\204/ex10.test.ts" "b/\354\240\225\354\227\260\354\261\204/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\240\225\354\227\260\354\261\204/ex10.ts" "b/\354\240\225\354\227\260\354\261\204/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\240\225\354\227\260\354\261\204/ex2.js" "b/\354\240\225\354\227\260\354\261\204/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\240\225\354\227\260\354\261\204/ex2.test.js" "b/\354\240\225\354\227\260\354\261\204/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\240\225\354\227\260\354\261\204/ex3.js" "b/\354\240\225\354\227\260\354\261\204/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\240\225\354\227\260\354\261\204/ex3.test.js" "b/\354\240\225\354\227\260\354\261\204/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\240\225\354\227\260\354\261\204/ex4.js" "b/\354\240\225\354\227\260\354\261\204/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\240\225\354\227\260\354\261\204/ex4.test.js" "b/\354\240\225\354\227\260\354\261\204/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\240\225\354\227\260\354\261\204/ex5.js" "b/\354\240\225\354\227\260\354\261\204/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\240\225\354\227\260\354\261\204/ex5.test.js" "b/\354\240\225\354\227\260\354\261\204/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\240\225\354\227\260\354\261\204/ex6.test.ts" "b/\354\240\225\354\227\260\354\261\204/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\240\225\354\227\260\354\261\204/ex6.ts" "b/\354\240\225\354\227\260\354\261\204/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\240\225\354\227\260\354\261\204/ex7.test.ts" "b/\354\240\225\354\227\260\354\261\204/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\240\225\354\227\260\354\261\204/ex7.ts" "b/\354\240\225\354\227\260\354\261\204/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\240\225\354\227\260\354\261\204/ex8.ts" "b/\354\240\225\354\227\260\354\261\204/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\240\225\354\227\260\354\261\204/ex9.js" "b/\354\240\225\354\227\260\354\261\204/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\240\225\354\227\260\354\261\204/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\240\225\354\244\221\354\235\274/ex1/book-edit.html" "b/\354\240\225\354\244\221\354\235\274/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\244\221\354\235\274/ex1/index.html" "b/\354\240\225\354\244\221\354\235\274/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\244\221\354\235\274/ex1/register.html" "b/\354\240\225\354\244\221\354\235\274/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\240\225\354\244\221\354\235\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\240\225\354\244\221\354\235\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\240\225\354\244\221\354\235\274/ex10.test.ts" "b/\354\240\225\354\244\221\354\235\274/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\240\225\354\244\221\354\235\274/ex10.ts" "b/\354\240\225\354\244\221\354\235\274/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\240\225\354\244\221\354\235\274/ex2.js" "b/\354\240\225\354\244\221\354\235\274/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\240\225\354\244\221\354\235\274/ex2.test.js" "b/\354\240\225\354\244\221\354\235\274/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\240\225\354\244\221\354\235\274/ex3.js" "b/\354\240\225\354\244\221\354\235\274/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\240\225\354\244\221\354\235\274/ex3.test.js" "b/\354\240\225\354\244\221\354\235\274/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\240\225\354\244\221\354\235\274/ex4.js" "b/\354\240\225\354\244\221\354\235\274/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\240\225\354\244\221\354\235\274/ex4.test.js" "b/\354\240\225\354\244\221\354\235\274/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\240\225\354\244\221\354\235\274/ex5.js" "b/\354\240\225\354\244\221\354\235\274/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\240\225\354\244\221\354\235\274/ex5.test.js" "b/\354\240\225\354\244\221\354\235\274/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\240\225\354\244\221\354\235\274/ex6.test.ts" "b/\354\240\225\354\244\221\354\235\274/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\240\225\354\244\221\354\235\274/ex6.ts" "b/\354\240\225\354\244\221\354\235\274/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\240\225\354\244\221\354\235\274/ex7.test.ts" "b/\354\240\225\354\244\221\354\235\274/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\240\225\354\244\221\354\235\274/ex7.ts" "b/\354\240\225\354\244\221\354\235\274/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\240\225\354\244\221\354\235\274/ex8.ts" "b/\354\240\225\354\244\221\354\235\274/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\240\225\354\244\221\354\235\274/ex9.js" "b/\354\240\225\354\244\221\354\235\274/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\240\225\354\244\221\354\235\274/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\265\234\354\204\240\354\240\225/ex1/book-edit.html" "b/\354\265\234\354\204\240\354\240\225/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\354\204\240\354\240\225/ex1/index.html" "b/\354\265\234\354\204\240\354\240\225/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\354\204\240\354\240\225/ex1/register.html" "b/\354\265\234\354\204\240\354\240\225/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\354\204\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\265\234\354\204\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\265\234\354\204\240\354\240\225/ex10.test.ts" "b/\354\265\234\354\204\240\354\240\225/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\265\234\354\204\240\354\240\225/ex10.ts" "b/\354\265\234\354\204\240\354\240\225/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\265\234\354\204\240\354\240\225/ex2.js" "b/\354\265\234\354\204\240\354\240\225/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\265\234\354\204\240\354\240\225/ex2.test.js" "b/\354\265\234\354\204\240\354\240\225/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\265\234\354\204\240\354\240\225/ex3.js" "b/\354\265\234\354\204\240\354\240\225/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\265\234\354\204\240\354\240\225/ex3.test.js" "b/\354\265\234\354\204\240\354\240\225/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\265\234\354\204\240\354\240\225/ex4.js" "b/\354\265\234\354\204\240\354\240\225/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\265\234\354\204\240\354\240\225/ex4.test.js" "b/\354\265\234\354\204\240\354\240\225/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\265\234\354\204\240\354\240\225/ex5.js" "b/\354\265\234\354\204\240\354\240\225/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\265\234\354\204\240\354\240\225/ex5.test.js" "b/\354\265\234\354\204\240\354\240\225/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\265\234\354\204\240\354\240\225/ex6.test.ts" "b/\354\265\234\354\204\240\354\240\225/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\265\234\354\204\240\354\240\225/ex6.ts" "b/\354\265\234\354\204\240\354\240\225/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\265\234\354\204\240\354\240\225/ex7.test.ts" "b/\354\265\234\354\204\240\354\240\225/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\265\234\354\204\240\354\240\225/ex7.ts" "b/\354\265\234\354\204\240\354\240\225/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\265\234\354\204\240\354\240\225/ex8.ts" "b/\354\265\234\354\204\240\354\240\225/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\265\234\354\204\240\354\240\225/ex9.js" "b/\354\265\234\354\204\240\354\240\225/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\265\234\354\204\240\354\240\225/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\265\234\355\230\201\355\203\234/ex1/book-edit.html" "b/\354\265\234\355\230\201\355\203\234/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\230\201\355\203\234/ex1/index.html" "b/\354\265\234\355\230\201\355\203\234/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\230\201\355\203\234/ex1/register.html" "b/\354\265\234\355\230\201\355\203\234/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\230\201\355\203\234/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\265\234\355\230\201\355\203\234/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\265\234\355\230\201\355\203\234/ex10.test.ts" "b/\354\265\234\355\230\201\355\203\234/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\265\234\355\230\201\355\203\234/ex10.ts" "b/\354\265\234\355\230\201\355\203\234/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\265\234\355\230\201\355\203\234/ex2.js" "b/\354\265\234\355\230\201\355\203\234/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\265\234\355\230\201\355\203\234/ex2.test.js" "b/\354\265\234\355\230\201\355\203\234/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\265\234\355\230\201\355\203\234/ex3.js" "b/\354\265\234\355\230\201\355\203\234/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\265\234\355\230\201\355\203\234/ex3.test.js" "b/\354\265\234\355\230\201\355\203\234/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\265\234\355\230\201\355\203\234/ex4.js" "b/\354\265\234\355\230\201\355\203\234/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\265\234\355\230\201\355\203\234/ex4.test.js" "b/\354\265\234\355\230\201\355\203\234/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\265\234\355\230\201\355\203\234/ex5.js" "b/\354\265\234\355\230\201\355\203\234/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\265\234\355\230\201\355\203\234/ex5.test.js" "b/\354\265\234\355\230\201\355\203\234/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\265\234\355\230\201\355\203\234/ex6.test.ts" "b/\354\265\234\355\230\201\355\203\234/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\265\234\355\230\201\355\203\234/ex6.ts" "b/\354\265\234\355\230\201\355\203\234/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\265\234\355\230\201\355\203\234/ex7.test.ts" "b/\354\265\234\355\230\201\355\203\234/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\265\234\355\230\201\355\203\234/ex7.ts" "b/\354\265\234\355\230\201\355\203\234/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\265\234\355\230\201\355\203\234/ex8.ts" "b/\354\265\234\355\230\201\355\203\234/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\265\234\355\230\201\355\203\234/ex9.js" "b/\354\265\234\355\230\201\355\203\234/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\265\234\355\230\201\355\203\234/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\354\265\234\355\232\250\354\204\235/ex1/book-edit.html" "b/\354\265\234\355\232\250\354\204\235/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\232\250\354\204\235/ex1/index.html" "b/\354\265\234\355\232\250\354\204\235/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\232\250\354\204\235/ex1/register.html" "b/\354\265\234\355\232\250\354\204\235/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\354\265\234\355\232\250\354\204\235/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\354\265\234\355\232\250\354\204\235/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\354\265\234\355\232\250\354\204\235/ex10.test.ts" "b/\354\265\234\355\232\250\354\204\235/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\354\265\234\355\232\250\354\204\235/ex10.ts" "b/\354\265\234\355\232\250\354\204\235/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\354\265\234\355\232\250\354\204\235/ex2.js" "b/\354\265\234\355\232\250\354\204\235/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\354\265\234\355\232\250\354\204\235/ex2.test.js" "b/\354\265\234\355\232\250\354\204\235/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\354\265\234\355\232\250\354\204\235/ex3.js" "b/\354\265\234\355\232\250\354\204\235/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\354\265\234\355\232\250\354\204\235/ex3.test.js" "b/\354\265\234\355\232\250\354\204\235/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\354\265\234\355\232\250\354\204\235/ex4.js" "b/\354\265\234\355\232\250\354\204\235/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\354\265\234\355\232\250\354\204\235/ex4.test.js" "b/\354\265\234\355\232\250\354\204\235/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\354\265\234\355\232\250\354\204\235/ex5.js" "b/\354\265\234\355\232\250\354\204\235/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\354\265\234\355\232\250\354\204\235/ex5.test.js" "b/\354\265\234\355\232\250\354\204\235/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\354\265\234\355\232\250\354\204\235/ex6.test.ts" "b/\354\265\234\355\232\250\354\204\235/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\354\265\234\355\232\250\354\204\235/ex6.ts" "b/\354\265\234\355\232\250\354\204\235/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\354\265\234\355\232\250\354\204\235/ex7.test.ts" "b/\354\265\234\355\232\250\354\204\235/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\354\265\234\355\232\250\354\204\235/ex7.ts" "b/\354\265\234\355\232\250\354\204\235/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\354\265\234\355\232\250\354\204\235/ex8.ts" "b/\354\265\234\355\232\250\354\204\235/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\354\265\234\355\232\250\354\204\235/ex9.js" "b/\354\265\234\355\232\250\354\204\235/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\354\265\234\355\232\250\354\204\235/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\355\225\234\354\204\261\353\257\274/ex1/book-edit.html" "b/\355\225\234\354\204\261\353\257\274/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\234\354\204\261\353\257\274/ex1/index.html" "b/\355\225\234\354\204\261\353\257\274/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\234\354\204\261\353\257\274/ex1/register.html" "b/\355\225\234\354\204\261\353\257\274/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\234\354\204\261\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\355\225\234\354\204\261\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\355\225\234\354\204\261\353\257\274/ex10.test.ts" "b/\355\225\234\354\204\261\353\257\274/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\355\225\234\354\204\261\353\257\274/ex10.ts" "b/\355\225\234\354\204\261\353\257\274/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\355\225\234\354\204\261\353\257\274/ex2.js" "b/\355\225\234\354\204\261\353\257\274/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\355\225\234\354\204\261\353\257\274/ex2.test.js" "b/\355\225\234\354\204\261\353\257\274/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\355\225\234\354\204\261\353\257\274/ex3.js" "b/\355\225\234\354\204\261\353\257\274/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\355\225\234\354\204\261\353\257\274/ex3.test.js" "b/\355\225\234\354\204\261\353\257\274/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\355\225\234\354\204\261\353\257\274/ex4.js" "b/\355\225\234\354\204\261\353\257\274/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\355\225\234\354\204\261\353\257\274/ex4.test.js" "b/\355\225\234\354\204\261\353\257\274/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\355\225\234\354\204\261\353\257\274/ex5.js" "b/\355\225\234\354\204\261\353\257\274/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\355\225\234\354\204\261\353\257\274/ex5.test.js" "b/\355\225\234\354\204\261\353\257\274/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\355\225\234\354\204\261\353\257\274/ex6.test.ts" "b/\355\225\234\354\204\261\353\257\274/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\355\225\234\354\204\261\353\257\274/ex6.ts" "b/\355\225\234\354\204\261\353\257\274/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\355\225\234\354\204\261\353\257\274/ex7.test.ts" "b/\355\225\234\354\204\261\353\257\274/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\355\225\234\354\204\261\353\257\274/ex7.ts" "b/\355\225\234\354\204\261\353\257\274/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\355\225\234\354\204\261\353\257\274/ex8.ts" "b/\355\225\234\354\204\261\353\257\274/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\355\225\234\354\204\261\353\257\274/ex9.js" "b/\355\225\234\354\204\261\353\257\274/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\355\225\234\354\204\261\353\257\274/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\355\225\250\355\230\225\354\243\274/ex1/book-edit.html" "b/\355\225\250\355\230\225\354\243\274/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\250\355\230\225\354\243\274/ex1/index.html" "b/\355\225\250\355\230\225\354\243\274/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\250\355\230\225\354\243\274/ex1/register.html" "b/\355\225\250\355\230\225\354\243\274/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\225\250\355\230\225\354\243\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\355\225\250\355\230\225\354\243\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\355\225\250\355\230\225\354\243\274/ex10.test.ts" "b/\355\225\250\355\230\225\354\243\274/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\355\225\250\355\230\225\354\243\274/ex10.ts" "b/\355\225\250\355\230\225\354\243\274/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\355\225\250\355\230\225\354\243\274/ex2.js" "b/\355\225\250\355\230\225\354\243\274/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\355\225\250\355\230\225\354\243\274/ex2.test.js" "b/\355\225\250\355\230\225\354\243\274/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\355\225\250\355\230\225\354\243\274/ex3.js" "b/\355\225\250\355\230\225\354\243\274/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\355\225\250\355\230\225\354\243\274/ex3.test.js" "b/\355\225\250\355\230\225\354\243\274/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\355\225\250\355\230\225\354\243\274/ex4.js" "b/\355\225\250\355\230\225\354\243\274/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\355\225\250\355\230\225\354\243\274/ex4.test.js" "b/\355\225\250\355\230\225\354\243\274/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\355\225\250\355\230\225\354\243\274/ex5.js" "b/\355\225\250\355\230\225\354\243\274/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\355\225\250\355\230\225\354\243\274/ex5.test.js" "b/\355\225\250\355\230\225\354\243\274/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\355\225\250\355\230\225\354\243\274/ex6.test.ts" "b/\355\225\250\355\230\225\354\243\274/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\355\225\250\355\230\225\354\243\274/ex6.ts" "b/\355\225\250\355\230\225\354\243\274/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\355\225\250\355\230\225\354\243\274/ex7.test.ts" "b/\355\225\250\355\230\225\354\243\274/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\355\225\250\355\230\225\354\243\274/ex7.ts" "b/\355\225\250\355\230\225\354\243\274/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\355\225\250\355\230\225\354\243\274/ex8.ts" "b/\355\225\250\355\230\225\354\243\274/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\355\225\250\355\230\225\354\243\274/ex9.js" "b/\355\225\250\355\230\225\354\243\274/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\355\225\250\355\230\225\354\243\274/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -} diff --git "a/\355\231\215\354\206\214\355\235\254/ex1/book-edit.html" "b/\355\231\215\354\206\214\355\235\254/ex1/book-edit.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\231\215\354\206\214\355\235\254/ex1/index.html" "b/\355\231\215\354\206\214\355\235\254/ex1/index.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\231\215\354\206\214\355\235\254/ex1/register.html" "b/\355\231\215\354\206\214\355\235\254/ex1/register.html" deleted file mode 100644 index e69de29..0000000 diff --git "a/\355\231\215\354\206\214\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" "b/\355\231\215\354\206\214\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" deleted file mode 100644 index fcebecb..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex1/\354\227\254\352\270\260\354\227\220tw\354\204\244\354\271\230\355\233\204\354\236\221\354\227\205\355\225\230\354\204\270\354\232\224.txt" +++ /dev/null @@ -1,3 +0,0 @@ -https://tailwindcss.com/docs/installation - -위 사이트의 가이드대로 설치 및 설정 후 작업하세요. \ No newline at end of file diff --git "a/\355\231\215\354\206\214\355\235\254/ex10.test.ts" "b/\355\231\215\354\206\214\355\235\254/ex10.test.ts" deleted file mode 100644 index 6218a79..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex10.test.ts" +++ /dev/null @@ -1,4 +0,0 @@ -import { ArrayList } from './ex10'; -console.log('🚀 ArrayList:', ArrayList); - -// 여기에 테스트코드를 작성하세요. diff --git "a/\355\231\215\354\206\214\355\235\254/ex10.ts" "b/\355\231\215\354\206\214\355\235\254/ex10.ts" deleted file mode 100644 index 1ffaef5..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex10.ts" +++ /dev/null @@ -1,71 +0,0 @@ -class Collection { - private readonly arr = Array(); - - constructor(...args: T[]) { - this.arr.push(...args); - } - - get _arr() { - return this.arr; - } - - push(...args: T[]) { - this.arr.push(...args); - return this.arr; - } - - get peek(): T | undefined { - return this.isQueue() ? this.arr[0] : this.arr.at(-1); - } - - get poll(): T | undefined { - return this.isQueue() ? this.arr.shift() : this.arr.pop(); - } - - remove() { - return this.poll; - } - - get length() { - return this.arr.length; - } - - get isEmpty() { - return !this.arr.length; - } - - clear() { - this.arr.length = 0; - } - - iterator() { - return this[Symbol.iterator](); - } - - // [1, 2, 3] - *[Symbol.iterator]() { - for (let i = this.length - 1; i >= 0; i -= 1) { - yield this.toArray()[i]; - } - } - - toArray() { - return this.isQueue() ? this.arr.toReversed() : this.arr; - } - - print() { - console.log(`<${this.constructor.name}: [${this.toArray()}]>`); - } - - private isQueue() { - return this instanceof Queue; - } -} - -class Stack extends Collection {} -class Queue extends Collection {} - -// ArrayList 클래스를 작성하세요. -class ArrayList extends Collection {} - -export { Stack, Queue, ArrayList }; diff --git "a/\355\231\215\354\206\214\355\235\254/ex2.js" "b/\355\231\215\354\206\214\355\235\254/ex2.js" deleted file mode 100644 index 6b95f04..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex2.js" +++ /dev/null @@ -1,4 +0,0 @@ -// range 함수를 작성하세요. -const range = (start, end, step = start > end ? -1 : 1) => { }; - -module.exports = { range }; diff --git "a/\355\231\215\354\206\214\355\235\254/ex2.test.js" "b/\355\231\215\354\206\214\355\235\254/ex2.test.js" deleted file mode 100644 index cbdb2e8..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex2.test.js" +++ /dev/null @@ -1,46 +0,0 @@ -const assert = require('assert'); -const { range } = require('./ex2'); - -assert.deepStrictEqual(range(1, 10, 1), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(1, 10, 2), [1, 3, 5, 7, 9]); -assert.deepStrictEqual(range(1, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -assert.deepStrictEqual(range(10, 1), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); - -assert.deepStrictEqual(range(5, 5, 0), [5]); -assert.deepStrictEqual(range(1, 5, 0), [1]); -assert.deepStrictEqual(range(5, 5, -1), [5]); -assert.deepStrictEqual(range(5, 5), [5]); -assert.deepStrictEqual(range(0, 0, 5), [0]); -assert.deepStrictEqual(range(1, 5, -1), []); - -assert.deepStrictEqual(range(1, 5, 6), [1]); -assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(-3, 0), [-3, -2, -1, 0]); - -assert.deepStrictEqual(range(5, 1, 1), []); -assert.deepStrictEqual(range(0, -1), [0, -1]); -assert.deepStrictEqual(range(0, -3), [0, -1, -2, -3]); -assert.deepStrictEqual(range(5, 1), [5, 4, 3, 2, 1]); -assert.deepStrictEqual(range(10, 1, -2), [10, 8, 6, 4, 2]); - -assert.deepStrictEqual(range(5), [1, 2, 3, 4, 5]); -assert.deepStrictEqual(range(0), [0]); -assert.deepStrictEqual(range(0, 0), [0]); -assert.deepStrictEqual(range(2, 1, -5), [2]); -assert.deepStrictEqual(range(0, -1, -5), [0]); -assert.deepStrictEqual(range(-5), [-5, -4, -3, -2, -1]); -assert.deepStrictEqual( - range(50), - Array.from({ length: 50 }, (_, i) => i + 1) -); -assert.deepStrictEqual( - range(1, 150, 3), - Array.from({ length: 50 }, (_, i) => i * 3 + 1) -); - -assert.deepStrictEqual( - range(1, 2, 0.1), - [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2] -); - -console.log(range(1, 2, 0.1)); diff --git "a/\355\231\215\354\206\214\355\235\254/ex3.js" "b/\355\231\215\354\206\214\355\235\254/ex3.js" deleted file mode 100644 index b1b0d75..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex3.js" +++ /dev/null @@ -1,3 +0,0 @@ -Array.prototype.sortBy = function (sortProp = '') { - return this; -}; diff --git "a/\355\231\215\354\206\214\355\235\254/ex3.test.js" "b/\355\231\215\354\206\214\355\235\254/ex3.test.js" deleted file mode 100644 index 6c27a4d..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex3.test.js" +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -require('./ex3'); - -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; -const kim = { id: 2, name: 'Kim', city: 'Seoul', dept: 2 }; -const lee = { id: 3, name: 'Lee', city: 'Daegu', dept: 2 }; -const users = [lee, hong, kim]; - -assert.deepStrictEqual(users.sortBy('id'), [hong, kim, lee]); -assert.deepStrictEqual(users.sortBy('name:desc'), [lee, kim, hong]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:asc'), [hong, lee, kim]); -assert.deepStrictEqual(users.sortBy('dept:desc,city:desc'), [kim, lee, hong]); -assert.deepStrictEqual(users.sortBy('name:desc,id:,dept:desc'), [ - kim, - lee, - hong, -]); -assert.deepStrictEqual(users.sortBy('dept:desc,id'), [hong, kim, lee]); diff --git "a/\355\231\215\354\206\214\355\235\254/ex4.js" "b/\355\231\215\354\206\214\355\235\254/ex4.js" deleted file mode 100644 index 9ede02f..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex4.js" +++ /dev/null @@ -1,3 +0,0 @@ -function deepCopy(obj) {} - -module.exports = { deepCopy }; diff --git "a/\355\231\215\354\206\214\355\235\254/ex4.test.js" "b/\355\231\215\354\206\214\355\235\254/ex4.test.js" deleted file mode 100644 index 2699ce8..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex4.test.js" +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert'); -const { deepCopy } = require('./ex4'); - -const arr = [1, 2, 3]; -const hong = { id: 1, name: 'Hong', city: 'Busan', dept: 1 }; - -const kim = { - nid: 3, - addr: 'Pusan', - arr: [1, 2, 3, { aid: 1 }, [10, 20]], - oo: { id: 1, name: 'Hong', addr: { city: 'Seoul' } }, - xx: null, - yy: function () { - console.log(this.oo); - }, - yyy() { - console.log(this.oo); - }, - [Symbol()]: 9, - [Symbol()]: Symbol('symbol2'), - zs: new Set([arr, hong]), - zws: new WeakSet([arr, hong]), - zm: new Map([[hong, arr]]), - zwm: new WeakMap([[hong, arr]]), -}; -const newKim = deepCopy(kim); -assert.deepStrictEqual(newKim, kim, 'deepCopy equal fail!'); -newKim.addr = 'Daegu'; -newKim.oo.name = 'Kim'; -assert.notDeepStrictEqual(newKim, kim, 'Not Valid Deep Copy!'); -newKim.arr[0] = 100; -newKim.arr[3].aid = 200; -newKim.arr[4][1] = 300; -newKim.oo.addr.city = 'Daejeon'; -assert.notStrictEqual(kim.arr[4][1], newKim.arr[4][1], 'pass2: 다르지 않아요!'); -assert.notStrictEqual( - kim.oo.addr.city, - newKim.oo.addr.city, - 'Not Pass3: city가 다르지 않아요!' -); diff --git "a/\355\231\215\354\206\214\355\235\254/ex5.js" "b/\355\231\215\354\206\214\355\235\254/ex5.js" deleted file mode 100644 index 464a05a..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex5.js" +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - searchByKoreanInitialSound: (data, firstSounds) => {}, -}; diff --git "a/\355\231\215\354\206\214\355\235\254/ex5.test.js" "b/\355\231\215\354\206\214\355\235\254/ex5.test.js" deleted file mode 100644 index 8d966e8..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex5.test.js" +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -const { searchByKoreanInitialSound } = require('./ex5'); - -const s = ['강원도 고성군', '고성군 토성면', '토성면 북면', '북면', '김1수']; -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅇ'), [ - '강원도 고성군', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱㅅㄱ'), [ - '강원도 고성군', - '고성군 토성면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅌㅅㅁ'), [ - '고성군 토성면', - '토성면 북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅂㅁ'), [ - '토성면 북면', - '북면', -]); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㅍㅁ'), []); -assert.deepStrictEqual(searchByKoreanInitialSound(s, 'ㄱ1ㅅ'), ['김1수']); diff --git "a/\355\231\215\354\206\214\355\235\254/ex6.test.ts" "b/\355\231\215\354\206\214\355\235\254/ex6.test.ts" deleted file mode 100644 index 680c5e6..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex6.test.ts" +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { promiseAllSettled, randTime } from './ex6'; - -(async function testNormal() { - assert.deepStrictEqual( - await promiseAllSettled([randTime(1), randTime(2), randTime(3)]), - await Promise.allSettled([randTime(1), randTime(2), randTime(3)]) - ); -})(); - -(async function testWithReject() { - assert.deepStrictEqual( - await promiseAllSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]), - await Promise.allSettled([ - randTime(11), - Promise.reject('REJECT'), - randTime(33), - ]) - ); -})(); diff --git "a/\355\231\215\354\206\214\355\235\254/ex6.ts" "b/\355\231\215\354\206\214\355\235\254/ex6.ts" deleted file mode 100644 index 424ca54..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex6.ts" +++ /dev/null @@ -1,4 +0,0 @@ -export const randTime = (val: T): Promise => - new Promise(resolve => setTimeout(resolve, Math.random() * 1000, val)); - -export function promiseAllSettled(promises: Promise[]) {} diff --git "a/\355\231\215\354\206\214\355\235\254/ex7.test.ts" "b/\355\231\215\354\206\214\355\235\254/ex7.test.ts" deleted file mode 100644 index 62b881d..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex7.test.ts" +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'assert'; -import { getPosts } from './ex7'; - -async function test(userId: string | number) { - const posts = await getPosts(userId); - - assert.strictEqual(posts?.length, 10); - assert.strictEqual(posts?.at(-1)?.comments?.length, 5); - assert.deepStrictEqual(posts[0], { - postId: 1, - title: - 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', - comments: [ - { - postId: 1, - id: 1, - email: 'Eliseo@gardner.biz', - body: - 'laudantium enim quasi est quidem magnam voluptate ipsam eos\n' + - 'tempora quo necessitatibus\n' + - 'dolor quam autem quasi\n' + - 'reiciendis et nam sapiente accusantium', - }, - { - postId: 1, - id: 2, - email: 'Jayne_Kuhic@sydney.com', - body: - 'est natus enim nihil est dolore omnis voluptatem numquam\n' + - 'et omnis occaecati quod ullam at\n' + - 'voluptatem error expedita pariatur\n' + - 'nihil sint nostrum voluptatem reiciendis et', - }, - { - postId: 1, - id: 3, - email: 'Nikita@garfield.biz', - body: - 'quia molestiae reprehenderit quasi aspernatur\n' + - 'aut expedita occaecati aliquam eveniet laudantium\n' + - 'omnis quibusdam delectus saepe quia accusamus maiores nam est\n' + - 'cum et ducimus et vero voluptates excepturi deleniti ratione', - }, - { - postId: 1, - id: 4, - email: 'Lew@alysha.tv', - body: - 'non et atque\n' + - 'occaecati deserunt quas accusantium unde odit nobis qui voluptatem\n' + - 'quia voluptas consequuntur itaque dolor\n' + - 'et qui rerum deleniti ut occaecati', - }, - { - postId: 1, - id: 5, - email: 'Hayden@althea.biz', - body: - 'harum non quasi et ratione\n' + - 'tempore iure ex voluptates in ratione\n' + - 'harum architecto fugit inventore cupiditate\n' + - 'voluptates magni quo et', - }, - ], - }); - - // 추가 테스트 코드를 작성하시오. -} - -test(1); diff --git "a/\355\231\215\354\206\214\355\235\254/ex7.ts" "b/\355\231\215\354\206\214\355\235\254/ex7.ts" deleted file mode 100644 index 62812ac..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex7.ts" +++ /dev/null @@ -1,3 +0,0 @@ -const POST_URL = 'https://jsonplaceholder.typicode.com/posts'; - -export async function getPosts(userId: number | string) {} diff --git "a/\355\231\215\354\206\214\355\235\254/ex8.ts" "b/\355\231\215\354\206\214\355\235\254/ex8.ts" deleted file mode 100644 index a67a2d2..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex8.ts" +++ /dev/null @@ -1,11 +0,0 @@ -// dummy(mock)입니다. 올바르게 수정하세요. -const debounce = (cb: any, delay: number) => (i: number) => {}; -const throttle = (cb: any, delay: number) => (i: number) => {}; - -// function throttle... - -const debo = debounce((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) debo(i); // 15 출력 - -const thro = throttle((a: number) => console.log(a + 1), 500); -for (let i = 10; i < 15; i++) thro(i); // 11 출력 diff --git "a/\355\231\215\354\206\214\355\235\254/ex9.js" "b/\355\231\215\354\206\214\355\235\254/ex9.js" deleted file mode 100644 index ec3044f..0000000 --- "a/\355\231\215\354\206\214\355\235\254/ex9.js" +++ /dev/null @@ -1,68 +0,0 @@ -const MENU = { - 짜장: { price: 7000 }, - 짬뽕: { price: 9900 }, - 탕슉: { price: 25000, taxfree: 1 }, -}; - -const LABEL_SIZE = 6; -const PRICE_SIZE = 7; - -function bill(tableNo) { - const ordered = []; - const tot = { price: 0, tax: 0 }; - - return { - order(item) { - ordered.push(item); - const { price, taxfree } = MENU[item]; - tot.price += price; - tot.tax += taxfree ? 0 : calcTax(price); - }, - - printBill() { - console.log(`\n\nTable. ${tableNo}`); - printLine(); - for (const item of ordered) { - const { price, taxfree } = MENU[item]; - console.log('*', item); - f`공급가액: ${price}원`; - f`부가세액: ${taxfree ? 0 : calcTax(price)}원`; - printLine('-'); - } - f`주문합계: ${tot.price}원`; - f`주문합계: ${tot.tax}원`; - printLine(); - }, - }; -} - -const table1 = bill(1); -table1.order('짜장'); -table1.order('짬뽕'); -table1.printBill(); - -const table2 = bill(2); -table2.order('짜장'); -table2.printBill(); - -table1.order('탕슉'); -table1.printBill(); - -table2.order('짬뽕'); -table2.printBill(); - -function f([label, unit], price) { - console.log(`${label.padEnd(LABEL_SIZE, ' ')} ${priceFmt(price)}`); -} - -function priceFmt(price, unit = '원') { - return price.toLocaleString().padStart(PRICE_SIZE, ' ') + unit; -} - -function printLine(flag = '=') { - console.log(flag.repeat(LABEL_SIZE * 2 + PRICE_SIZE + 2)); -} - -function calcTax(price) { - return Math.round((price / 1.1) * 0.1); -}