首页 > 解决方案 > Equivalent of python's range in Javascript

问题描述

I want to know what is the equivalent code for the python's range(start,stop,step=1). If anyone knows, I am really grateful for the help.

标签: javascriptpython

解决方案


You can try this code instead, but you need to create a function first:

var number_array = [];

function range(start,stop) {
    for (i =start; i < (stop+1); i++) {
        number_array.push(i);
    }
    return number_array;
}

推荐阅读