I have written these two functions to get a random number 1 through 10 X number of times.
function randomNum(){
$availableNums = 1..9
$availableNums | Get-Random
}
function randNumXTimes($x){
$global:rando = @()
for($i; $i -lt $x; $i++){
$rando += randomNum;
$rando
}
}
If I do the randomNum
function it will always do what it looks like it should do, it will give me a random number 1 through 9.
Then I have this function randNumXTimes
, if I run this function which calls the randomNum
function it now produces random two digit numbers, they are only supposed to be single digit numbers.
What the heck?
Example results from randomNum: 6 7 2 7 8 2
Example results from randNumXTimes which simply runs the randomNum function X number of times...
(randNumXTimes 10): 7 12 20 25 30 36 43 45 51 53
My question is, WHY does this do this when it looks like it should only produce single digit numbers X number of times? How can I fix this?