I'm new to Javascript and I'm trying to create a function that rotates the array depending on how many times number is === to, using splice. I have come up with this so far but I face an undefined error:
var count = 0
function rotate(arr, num) {
while (count < num)
{
arr.splice(0,0, arr.indexOf(3));
arr.splice(4,1);
count++
}
}
console.log(rotate(["Harry", "Sarah", "Oscar", "Tina"], 2));