Creating Random Array Javascript Length Function In R