After running this request my users value in the api would be altered to be the previous length of the array, plus one. After banging my head against the wall, asking a friend, and eventually asking one of our instructors about why it was happening, my instructor asked something that might seem very obvious: “What’s the return value for .push()?”.
The nature of the Flatiron program encourages us to grow extremely fast as programmers, but we need to be mindful of these subtle differences, lest we build a shaky foundation. It’s sometimes more important to spend a couple extra minutes looking up the documentation for a feature you think you understand in order to save yourself the time you would need to spend trying to debug if you misremember a detail about the feature. Just something to keep in mind.
The method removes the last element from an array and returns that element. This method changes the length of the…
The push() method adds one or more elements to the end of an array and returns the new length of the array. The…
Append - Pushes the given object(s) on to the end of this array. This expression returns the array itself, so several…