The order of properties in objects in JS, Cash Register Problem

Tell us what’s happening:
I am very confused about why this happening in my code.
I am simply iterating through the array const s. I know this is not functional programming, but I ran tests with for (let i in s) or other variations of for loops.
It keeps iterating one extra time.

Thanks guys.

  **Your code so far**

// The global variable
const s = [23, 65, 98, 5];

Array.prototype.myMap = function(callback) {
const newArray = [];
// Only change code below this line
for (let i = 0; i < s.length; i ++){

// Only change code above this line
return newArray;

const new_s = s.myMap(function(item) {
return item * 2;
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55

Challenge: Implement map on a Prototype

Link to the challenge:

I don’t understand what you are asking. Can you provide more details?

I’m not sure how this relates to the Cash Register problem either.

Note: Your prototype method should not reference a specific instance of an array, such as s.

The this keyword is important here. You should not be using s.length because the function will only check for that variable’s length. When you use the method .myMap() on the array s it returns a value of this array that the method is working on. this array in this case is s. The callback function needs to be invoked inside the myMap function body