I'm attempting to generate 10 random numbers 3 times and capture the hi, the lo, and last in every 10 number batch. I create an array of the hi/lo/last that gets pushed into another array so I can keep track of the numbers. Unfortunately the push command below seems to be only adding the last hi/lo/last 3 times, instead of each hi/lo/last. Not sure what I'm doing wrong.
Also, I clearly am not an expert programmer having worked mostly with VBA in excel where I could step through a program. Is there any way to do that in Sublime with Javascript? I'm working in a windows environment, using Sublime Text 2, with a Node build for Javascript.
Thanks in advance for the help.
var price;
var hiPrice;
var loPrice;
var intervalPrices = []
var initialPrices = [];
var rows = 3;
var columns = 3;
var randomPrices = function(){
price = 1
hiPrice = price
loPrice = price
for (var i = 1; i <= 30; i++){
price = Math.round((price+(Math.random()*2-1)/1000)*100000)/100000
priceIs()
if (i%10 == 0){
intervalPrices[0] = hiPrice
intervalPrices[1] = loPrice
intervalPrices[2] = price
initialPrices.push(intervalPrices)
hiPrice = price
loPrice = price
}
}
}
var priceIs = function(){
if (price >= hiPrice) {
hiPrice = price
}
if (price < loPrice) {
loPrice = price
}
}
randomPrices()
console.log(initialPrices)