I'm trying to remove Rohan
from this array and return it without the city using splice but I have to call -5 to show the whole array: lotrCitiesArray.splice(-5)
lotrCitiesArray = ["Mordor","Gondor","Rohan","Beleriand","Mirkwood","Dead Marshes","Rhun","Harad"];
results should be ["Mordor","Gondor","Beleriand","Mirkwood","Dead Marshes","Rhun","Harad"]
;
My code thus far:
function kata8() {
let newCopy = lotrCitiesArray.slice(0)
let removeRohan = newCopy.splice(-5)
let sevElement = document.createElement("div");
sevElement.textContent = JSON.stringify(removeRohan);
document.getElementById('kata8').appendChild(sevElement)
return [removeRohan];
}