• Question
  • Is there a way to check an added item's index number thing (gamelab)

pluto well why not try removing it? read the error and you'll understand why

pluto Array.prototype.push shifts a piece of data into a current array, then returns the current .length attribute of the new array this function also accepts multiple parameters to be allowed to be put into the array but with this you'll only be able to access the last element added to the array.... as for the reason the -1, if you've ever worked with array indices you'll know that it always starts at 0, and the .length attribute is off by one.... by subtracting the return value from .push() and subtracting it by 1 we get the data you just appended to the array.... I don't know how to make this any simpler though.... debugging is a huge part of programming you should have understood that getting undefined from the array meant that you weren't in the correct index to read what you just added

    Varrience about the part of where you can only check the last element (if im correct this is the item in the array), is there any other way to check all the items?

      pluto yes.... you can brute force your way through all the elements using a basic iterator, i refered to this via the first post, though asking for a way to check all of them contradicts your post, no?

      var arr = [1,2,5,6,9,4,2,0];
      for(var i = 0; i < arr.length; i++) {
      console.log(arr[i]);
      }

        💀

        do arrays act like sprites or are they like a value or something how do they collide or interact

        simple explanation; one variable, 2 or more pieces of data

        simple explanation; one value, more value, nested value, headache

        my two hours of sleep brain still cant figure this out

          Chat