JaveScript
-
DOM에 직접 접근하기 (useRef)개발공부/React 2023. 10. 26. 15:55
오늘은~! useRef에 대해 자세하게 공부해보자. 소분소분 프로젝트에서 회원가입을 담당했는데 정말 고민이 많았다. 실시간 유효성 검사하여 사용자에게 안내 메시지도 보여줘야 하고, input 태그가 각자 리렌더링 되도록 해야하고... 허헣.. 나름 신경써서 작업했는데 아쉽게도 라이트 하우스 90점을 넘지 못해 개선중이다. 일단 1차로 해결하고 싶은 부분은 리렌더링이다. 단순하게 컴포넌트를 상세하게 분류하거나, 아니면 커스텀 훅을 활용하거나 등등 여러가지 고민을 했지만 비밀번호 확인 때문에 쉽지가 않다. 사용자가 입력한 비밀번호와 일치하는지 확인하기 위해서는 같은 단에 선언해야 하는데.. 이 경우 하나만 변해도 다른 부분이 같이 리렌더링이 된다... 일단 객체를 활용해서 그나마 리렌더링 덜 하게 바꾸긴 했..
-
[JS] 다트 게임 (1차)이노베이션 캠프/3주차_알고리즘 2023. 6. 21. 14:32
문제 https://school.programmers.co.kr/learn/courses/30/lessons/17682 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 function solution(dartResult) { let result = []; // 1) 결과 값을 저장한 변수 선언 및 할당 let pat = /\d+[A-Z][*#]?/g; // 2) 값을 잘라올 수 있는 패턴 생성 let gameResults = dartResult.match(pat); // 3) match 사용하여 생성된 패턴과 일치하는 문자열 배열로 저장 let ..
-
[JS] K번째수이노베이션 캠프/3주차_알고리즘 2023. 6. 21. 11:46
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 function solution(array, commands) { let result = []; // 1) 결과 값 저장할 변수 선언 및 할당 // 2) for문 사용하여 배열의 원소의 접근 for (let i=0; i a-b); // 2-2) 잘라온 배열 내 특정 인덱스의 값 가져와 저장 result.push(temps[data[2]-1]); } return result; } 참..
-
[JS] 모의고사이노베이션 캠프/3주차_알고리즘 2023. 6. 19. 19:20
문제 https://school.programmers.co.kr/learn/courses/30/lessons/42840 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 최종 제출 function solution(answers) { let pattern1 = [1, 2, 3, 4, 5]; let pattern2 = [2, 1, 2, 3, 2, 4, 2, 5]; let pattern3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; let temps = [0, 0, 0]; let totallen = answers.length; for (..
-
[JS] 최소직사각형이노베이션 캠프/3주차_알고리즘 2023. 6. 17. 21:52
문제 https://school.programmers.co.kr/learn/courses/30/lessons/86491 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 해당 문제의 경우 첫 작성 코드를 바로 최종 제출함. 최종 제출 function solution(sizes) { let longs = []; let shorts = []; for (let i=0; i h) { // 가로의 값이 더 클 때 longs.push(w); shorts.push(h); } else { // 세로의 값이 더 클 때 longs.push(h); shorts.pus..
-
[JS] 3진법 뒤집기이노베이션 캠프/3주차_알고리즘 2023. 6. 17. 21:45
문제 https://school.programmers.co.kr/learn/courses/30/lessons/68935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 첫 번째 문제 풀이 방법 function solution(n) { let temp = n.toString(3); // 10진법 -> 3진법 let temps = temp.split("").reverse(); // 배열로 변환 후 뒤집기 let temp1 = temps.join(""); // 문자열로 만들기 return parseInt(temp1, 3); // 3진법으로 변환하여 리..