I wrote this function :

function range(start,stop,step) {
    var array =[];
    for ( var i = start; i <= stop; i += step ){

        array.push(i);
    }
    return array;
}

var m = range(1,10);
console.log("length = " + m.length);

And it returns one.

Since, range returns an array , should't it be the array length?

Recommended Answers

You define the function with 3 parameters, but call it with 2

Jump to Post

All 2 Replies

You define the function with 3 parameters, but call it with 2

Right!
Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.