-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
해결됨
카드 맞추기 질문
23.07.12 01:12 작성 조회수 211
0
const total = 12;
const colors = ['red', 'orange', 'yellow', 'green', 'white', 'pink'];
let colorCopy = colors.concat(colors);
let shuffled = [];
let clicked = [];
let completed = [];
function shuffle() { // 피셔-예이츠 셔플
for(let i=0; colorCopy.length>0; i+=1) {
const randomIndex = Math.floor(Math.random() * colorCopy.length);
shuffled = shuffled.concat(colorCopy.splice(randomIndex, 1));
}
}
여기서
shuffled = shuffled.concat(colorCopy.splice(randomIndex, 1)); 이거를
shuffled.push(colorCopy.splice(randomIndex, 1)) 로 해도 상관이 없나요? concat으로 한 이유가 있을까요
답변을 작성해보세요.
0
답변 1