test

하태현·2022년 9월 14일
0
// 문제 1번
// indexX: '년/월/일'형식의 데이터가 시간 순으로 나열되어 있다.
// getFirstByYear: indexX내 각 년도의 가장 빠른 날짜만을 반환
const indexX = [
  '2013/1/24',
  '2013/1/25',
  '2013/1/26',
  '2013/1/27',

  '2014/1/4',
  '2014/1/5',
  '2014/1/6',
  '2014/1/7',
  '2014/1/8',
  '2014/1/9',

  '2015/1/1',
  '2015/1/2',
  '2015/1/3',

  '2016/1/1',
  '2016/1/2',
  '2016/1/3',
  '2016/1/4',
  '2016/1/5',
  '2016/1/6',
];

const getFirstByYear = (arr: string[]) => {
  return [];
};

getFirstByYear(indexX); // ['2013/1/24', '2014/1/4', '2015/1/1', '2016/1/1']

// 문제 2번
// specs: 제품 정보(id, tags)의 배열
// allTags: 선택가능한 모든 태그들
// st(n): allTags에서 유저가 선택한 태그들(ex: ['a', 'b'])
// getFilteredSpecs: 제품정보(specs)중 유저가 선택한 태그들(st)를 모두 포함하는 제품들을 반환
const specs = [
  { id: 0, tags: ['a', 'b', 'c', 'd', 'e'] },
  { id: 1, tags: ['a', 'b', 'e'] },
  { id: 2, tags: ['f'] },
  { id: 3, tags: ['a', 'c', 'e'] },
];
const allTags = ['a', 'b', 'c', 'd', 'e', 'f']; // not used

const st1 = ['a'];
const st2 = ['c', 'a', 'e'];
const st3 = ['a', 'b'];

const getFilteredSpecs = (specs: { id: number; tags: string[] }[], selectedTags: string[]) => {
  return [];
};

getFilteredSpecs(specs, st1); // [{ id: 0, tags: [ 'a', 'b', 'c', 'd', 'e' ] }, { id: 1, tags: [ 'a', 'b', 'e' ] }, { id: 3, tags: [ 'a', 'c', 'e' ] }]
getFilteredSpecs(specs, st2); // [{ id: 0, tags: [ 'a', 'b', 'c', 'd', 'e' ] }, { id: 3, tags: [ 'a', 'c', 'e' ]}]
getFilteredSpecs(specs, st3); // [{ id: 0, tags: [ 'a', 'b', 'c', 'd', 'e' ] }, { id: 1, tags: [ 'a', 'b', 'e' ] }]
profile
왜?를 생각하며 개발하기, 다양한 프로젝트를 경험하는 것 또한 중요하지만 내가 사용하는 기술이 어떤 배경과 이유에서 만들어진 건지, 코드를 작성할 때에도 이게 최선의 방법인지를 끊임없이 질문하고 고민하자. 이 과정은 앞으로 개발자로 커리어를 쌓아 나갈 때 중요한 발판이 될 것이다.

0개의 댓글