본문 바로가기

JS20

[프로그래머스] Lv 1. 신고 결과 받기 - Javascript 풀이 문제 링크https://school.programmers.co.kr/learn/courses/30/lessons/92334 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이 function solution(id_list, report, k) { const idCount = id_list.length; const result = Array(idCount).fill(0); //각 유저별 신고 당한 횟수 const alreadyReport = []; //중복이 제거된 신고 배열 const record = Array.from({length: idCount}, ()=>[]); //신고기록.. 2025. 1. 11.
[프로그래머스] Lv 1. 숫자 문자열과 영단어 - Javascript 풀이 문제 링크https://school.programmers.co.kr/learn/courses/30/lessons/81301 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이function solution(s) { const numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']; numbers.forEach((number,index)=> { while(s.includes(number)){ s = s.replace(number, index); .. 2025. 1. 9.
[프로그래머스] Lv 1. 성격 유형 검사하기 - Javascript 풀이 문제 링크https://school.programmers.co.kr/learn/courses/30/lessons/118666 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 핵심 정리1. 구해야하는 것 : 검사자의 성격 유형 검사 결과 (지표 번호 순서 순)2. 입력 - survey : survey 배열의 각 원소는 성격 유형 쌍이다. (e.g., "RT" or "TR")3. 입력 - choices : choices 배열의 각 원소는 검사자가 선택한 질문의 선택지이다. 동의하는 정도가 1~7까지의 범위로 나누어져있다. 1~3 은 비동의를 나타낸다. 이는 성격 유형 쌍에서 전자가 해당한다.4는 중립5~7은.. 2025. 1. 8.
[프로그래머스] Lv 1. - 개인정보 수집 유효기간: Javascript 풀이 문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/150370 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이function solution(today, terms, privacies) { let answer = []; const todayTimestamp = new Date(today.replaceAll('.','-')).getTime(); //terms 배열을 { termKind, duration} 형태로 변환 const termsObj = {}; terms.forEach(term => { .. 2025. 1. 8.
[프로그래머스] Lv 1. - 가장 많이 받은 선물 : Javascript 풀이 문제원본 사이트: https://school.programmers.co.kr/learn/courses/30/lessons/258712 풀이function solution(friends, gifts) { const friendsCount = friends.length; //선물 기록 (2차원 배열) const records = Array.from({length: friendsCount}, () => Array(friendsCount).fill(0)); // 선물 지수 (1차원 배열) const giftScore = Array(friendsCount).fill(0); //선물 기록 및 선물 지수 계산 gifts.forEach(gift => { //각 문자열을.. 2025. 1. 5.
[Typescript] 문자열 내 괄호의 개수 계산하기 function processPlayerData(data: string): string[] { if (data.split('(').length - 1 > 1) { // 괄호가 2개 이상인 경우 (여러 선수 데이터) return data.split(' '); } else { // 괄호가 1개인 경우 (한 선수 데이터) return [data]; }}// 테스트const multiplePlayers = "신민재(3회) 박해민(7회) 김대원(7회)";const singlePlayer = "오스틴(1회 1사 1루서 우중간 2루타)";console.log(processPlayerData(multiplePlayers)); // 출력: ['신민재(3회)', '박해민(7회)', '김대원(7회.. 2024. 12. 26.