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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.