trying to get a count from an array in javascript

hey guys new to javascript and trying to run a simple count procedure in arrays

i have built an array from some prompts and am now trying to run a loop through to count negative and positive numbers

i understand the for loop context, would i have to build another emtpy array and push results to it?

this is what i have written up so far…

let array2 = []
    for (let i = 0; i < numberCount; i++) {
        if (array[i] > 0) {
            i == 1
            array2.push(i)
        }
    }

any help appreciated, dont burn me to hard!

20 thoughts on “trying to get a count from an array in javascript”

  1. Please clear. what you want…

    If you want to find the number of elements present in array , you can use .length property.

    let array = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
    let arrayCount = array.length
    
    Reply

Leave a Comment