Random values up and down an array [closed]

  algorithm, arrays, javascript, random

In JS, I’m trying to create an array of randomly selected ascending and descending elements from another array. How can I do this?

e.g.

let array = [1,2,3,4,5,6,7,8,9,10,11,12]

const up = 4
const down = 7

// some code

outputRadnomUpDown = [1,3,6,8,11,9,8,6,3,2,1]

Thanks for reading.

Source: Ask Javascript Questions

LEAVE A COMMENT