0

I need to add any number to random array to the preset position and and move elements after him. I just wrote code for random array how to continue?

var CreateArray = (...lengths) => lengths.map(length => (
  Array.from({
    length
  }, () => Math.floor(Math.random() * 3000000))
));
var randomarrays = (arrs) => {
  arrs.forEach(arr => {
    randomarray(arr);

  });
};
4
  • Use splice developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Commented Jun 21, 2018 at 16:26
  • can you explain more? i know about splice, but how to use it with that code that generate random array? Commented Jun 21, 2018 at 16:28
  • So you are asking how to insert a value into an array at a given index? If yes, dupe of stackoverflow.com/questions/586182/… Commented Jun 21, 2018 at 16:32
  • do you know any other method without "splice"? Commented Jun 21, 2018 at 16:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.