Push onto array argument in javascript -
i have following function:
function where(arr, num) { return arr.push(num); } where([40, 60], 50); // returns 3
i expecting return [40,60,50] returns 3.
thanks help.
the documentation states array.prototype.push()
returns length of array. need push new number , return array.
function where(arr, num) { arr.push(num); return arr; } myarray = where([40, 60], 50); // myarray === [40, 60, 50]
Comments
Post a Comment