[javascript] Array 셔플(랜덤), remove Array
2022. 1. 25.
//var this_numarry = new Array();
var this_numarry = ['09', '11', '23', '32', '15', '41', '19'];
function removeNumberArray(target_){
if(this_numarry != undefined && this_numarry.length > 0){
const index = this_numarry.indexOf(target_);
if (index > -1) { this_numarry.splice(index, 1); }
}
}
function setShuffleArray(array) {
let currentIndex = array.length, randomIndex; // While there remain elements to shuffle...
while (currentIndex != 0) { // Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--; // And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [ array[randomIndex], array[currentIndex]];
}
return array;
}
'JS_CSS' 카테고리의 다른 글
[jQuery] Scroll Animate 함수 (0) | 2022.11.29 |
---|---|
[javascript] a태그 카카오맵 길찾기 연결 (0) | 2022.07.03 |
[javascript] 3자리수 콤마 처리 (0) | 2021.12.09 |
[javascipt] script의 속성 async, defer (0) | 2021.09.13 |
[javascript] 개행, 공백 제거 (0) | 2021.06.22 |