I'm currently attempting to add a number to the end of an array without using the push function.
As it stands, my array is returning [1, 2, 3, 10], but when I check its length it shows 8. It seems like it's counting the array elements and the separator for numbers twice, resulting in 8, though I can't figure out why that's happening.
function addToArray(array, value){
arr = arr + ',' + value
return arr.length
}
var arr = [1, 2, 3]
console.log(addToArray(arr, 10)) // expecting 4, getting 8