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

ES6 String Duplicate #95

Closed
xyzdata opened this issue Mar 14, 2018 · 2 comments
Closed

ES6 String Duplicate #95

xyzdata opened this issue Mar 14, 2018 · 2 comments

Comments

@xyzdata
Copy link

xyzdata commented Mar 14, 2018

ES6 String Duplicate

https://github.com/yangshun/front-end-interview-handbook/blob/master/questions/javascript-questions.md#make-this-work

image

/**
 * @author xgqfrms
 * @license MIT
 * @description ES6 String Duplicate
 * @param {Array} arr
 */

let arr = [1, 2, 3, 4, 5];
const ES6_String_Duplicate = arr => `${arr.toString()},`.repeat(2).slice(0, -1).split(`,`).map(item => parseInt(item));
ES6_String_Duplicate(arr);
// (10) [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
@yangshun
Copy link
Owner

I'm sorry but this approach is convoluted and longer than it needs to be. I would rather not add this in.

@xyzdata
Copy link
Author

xyzdata commented Mar 15, 2018

OK, fine!

musmanraodev added a commit to musmanraodev/front-end-interview-handbook that referenced this issue May 26, 2023
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

2 participants