# 자바스크립트 스터디 2일차 ## 문제 1번. - 배열 자유롭게 다루기 ```javascript= let animals = [ "Aardvark", "Albatross", "Alligator", "Alpaca", "Ant", "Ape", "Armadillo", "Donkey", "Baboon", "Badger", "Barracuda", "Bat", "Bear", "Beaver", "Bee", "Bison", "Cat", "Caterpillar", "Cattle", "Chamois", "Cheetah", "Chicken", "Chimpanzee", "Chinchilla", "Chough", "Clam", "Cobra", "Cockroach", "Cod", "Cormorant", "Dugong", "Dunlin", "Eagle", "Echidna", "Eel", "Eland", "Elephant", "Elk", "Emu", "Falcon", "Ferret", "Finch", "Fish", "Flamingo", "Fly", "Fox", "Frog", "Gaur", "Gazelle", "Gerbil", "Giraffe", "Grasshopper", "Heron", "Herring", "Hippopotamus", "Hornet", "Horse", "Kangaroo", "Kingfisher", "Koala", "Kookabura", "Moose", "Narwhal", "Newt", "Nightingale", "Octopus", "Okapi", "Opossum", "Quail", "Quelea", "Quetzal", "Rabbit", "Raccoon", "Rail", "Ram", "Rat", "Raven", "Red deer", "Sandpiper", "Sardine", "Sparrow", "Spider", "Spoonbill", "Squid", "Squirrel", "Starling", "Stingray", "Tiger", "Toad", "Whale", "Wildcat", "Wolf", "Worm", "Wren", "Yak", "Zebra", ]; animals.pop(); // 맨 마지막 요소인 "Zebra" 제거. animals.push("Dog"); // 맨 마지막에 "Dog" 추가. animals.push("Mosquito", "Mouse", "Mule"); // 3가지 더 추가. console.log(animals.includes("Human")); // 배열에 "Human"이 있는가? console.log(animals.includes("Cat")); // 배열에 "Cat"이 있는가? animals[animals.indexOf("Red deer")] = "Deer"; // "Red deer"를 "Deer"로 변경. animals.splice(animals.indexOf("Spider"), 3); // "Spider"부터 3개의 원소 제거. animals.splice(animals.indexOf("Tiger")); // "Tiger"이후 싹 다 제거 let newAnimals = animals.slice( // B로 시작하는 원소들만 따로 저장. animals.indexOf("Baboon"), animals.indexOf("Bison") + 1, ); console.log(newAnimals); console.log(animals); ```