본문 바로가기

분류 전체보기154

Level2. 타겟 넘버(DFS/BFS) - JavaScript DFS를 활용해서 문제를 해결했다. numbers 배열에 들어 있는 각 원소를 노드라고 생각한다면 각 노드는 +노드, -노드의 두 분기로 나눠지게 된다. numbers가 [1,2,3]이라고 했을 때 실제 방문하는 노드는 1, 2, 3이 되는게 아니라 1 -> 2 -> 3 1 -> 2 -> -3 1 -> -2 -> 3 1 -> -2 -> -3 ... 처럼 노드가 달라진다. function solution(numbers, target) { var answer = 0; dfs(0, 0); return answer; function dfs(nodeIndex, totalNumber) { if (nodeIndex === numbers.length) { if (totalNumber === target) answer+.. 2021. 4. 19.
React에서 exceljs 사용하기 및 엑셀 내보내기(다운로드) 에러 해결 필수 library npm i exceljs npm i file-saver exceljs에서는 아쉽게도 client쪽에서 엑셀 다운로드가 지원되지 않는다고 합니다. 따라서 file-saver라는 library를 이용하여 다운로드 합니다. 예제 코드 입니다. import React from "react"; import * as ExcelJS from "exceljs"; import { saveAs } from "file-saver"; export default function Excel() { const handleExcel = async () => { const workbook = new ExcelJS.Workbook(); const worksheet = workbook.addWorksheet("My S.. 2021. 3. 31.
Visual Studio Code Shortcut 및 key binding 설정 keybinding.json에 설정 파일 -> 기본 설정 -> 바로가기 키 -> 오른쪽 상단 종이 아이콘 클릭 [ { // 줄 선택 "key": "shift+end", "command": "cursorEndSelect", "when": "textInputFocus" }, { // 라인 끝으로 이동 "key": "alt+s", "command": "cursorLineStart" }, { // 라인 시작으로 이동 "key": "alt+e", "command": "cursorLineEnd" }, { // 선택된 코드만 실행 "key": "ctrl+alt+r", "command": "workbench.action.terminal.runSelectedText" }, { // 10줄 위로 이동 "key": "ctr.. 2021. 3. 30.
Chrome: Illegal invocation. / IE: 호출 개체가 잘못되었습니다. Error에 대해서 알아보자. Javascript의 경우 this가 자유로운 편이다. 객체가 method를 가지고 있더라도 해당 method를 다른 객체가 호출할 수도 변수에 저장했다가 호출할 수도 있다. 예를 들어보면 Person class가 printName method를 가지고 있다. 이를 객체화 했지만 어느 시점에 person 객체가 가지고 있는 printName이라는 메서드만 필요하다고 가정한다면 다음과 같이 사용할 수 있다. class Person { constructor(name) { this.name = name; } printName() { console.log(this.name); } } const person = new Person("choi"); const printName = person.printName; p.. 2021. 2. 14.