Skip to content

[js] 第706天 写一个方法,传入一个整数参数,返回和参数一样长度且不重复的数组 #3719

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第706天 写一个方法,传入一个整数参数,返回和参数一样长度且不重复的数组

3+1官网

我也要出题

Activity

alanhe421

alanhe421 commented on Mar 21, 2021

@alanhe421
function createCertainLengthArray(length) {
  const arr = new Array(length).fill();
  arr.forEach((_, index) => {
    arr[index] = index;
  });
  return arr;
}
longhui520

longhui520 commented on Mar 22, 2021

@longhui520
function createArr(len){
  return Array.apply(null,{length:len}).map((_,index)=>{
    return index
  })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@alanhe421@longhui520

        Issue actions

          [js] 第706天 写一个方法,传入一个整数参数,返回和参数一样长度且不重复的数组 · Issue #3719 · haizlin/fe-interview