Using console.log to output the result of a push() on an array returns a number?

I just finished the Arrays lesson, and I was messing around with some of the methods. I was curious why I got a number output for this code:

const chalupa = [‘i love chalupas!’];

console.log(chalupa.push(‘tacos’, ‘burritos’, ‘gorditas’));

the output was 4

I thought it would output the items I was .push-ing

looking at the documentation and it says:

The push() method adds one or more elements to the end of an array and returns the new length of the array.

1 Like

I should have read the documentation! Thanks!

1 Like