I am trying to write a function on JS which accepts the given array and reverses it. I know that there is a special method for this, but there is a desire like a beginner to write manually. I give a code which for not clear to me reasons returns an empty array.
function reverseArray(myArray) { var newMyArray = []; for (var i = myArray.length; i > 0; i--) { newMyArray.unshift(myArray.pop()); } return newMyArray; }