프로그래머스 Level 1 - 로또의 최고 순위와 최저 순위 (Javascript)
문제 답안 function solution(lottos, win_nums) { let cnt = 0; let hiddenNum = 0; let rank = [0,0]; // 맞춘 갯수에 따른 등수 const obj = { 6: 1, 5: 2, 4: 3, 3: 4, 2: 5, 1: 6, 0: 6, }; // lottos 배열에서 0의 갯수를 hiddenNum에 넣어준다. for(let i = 0; i < lottos.length; i++){ if(lottos[i] == 0){ hiddenNum++; } // win_nums, lottos에 들어있는 숫자의 갯수를 cnt에 넣어준다. for(let j = 0; j < win_nums.length; j++){ if(lottos[i] == win_nums[j])..
2023. 11. 27.