Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #1

Open
Sapphire611 opened this issue Jun 4, 2021 · 2 comments
Open

Test #1

Sapphire611 opened this issue Jun 4, 2021 · 2 comments

Comments

@Sapphire611
Copy link
Owner

哈哈哈

@Sapphire611
Copy link
Owner Author

`javascript
"use strict";

const replaceArray = (arr) => {
let list = [];
for (let i = 0; i < arr.length; i += 2) {
if (arr[i + 1] <= arr.length && list.push(arr[i + 1]))
list.push(arr[i]);
}
return list;
}

// let arr = [1,2,3,4];
// let res = replaceArray(arr);
// console.log(res);
`

@Sapphire611
Copy link
Owner Author

"use strict";

const replaceArray = (arr) => {
  let list = [];
  for (let i = 0; i < arr.length; i += 2) {
    if (arr[i + 1] <= arr.length && list.push(arr[i + 1]))
      list.push(arr[i]);
  }
  return list;
}

// let arr = [1,2,3,4];
// let res = replaceArray(arr);
// console.log(res);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant