Commit f37d3fd2 authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent d932494e
...@@ -26,9 +26,27 @@ async function init() { ...@@ -26,9 +26,27 @@ async function init() {
balance=balance+arr[i].profit balance=balance+arr[i].profit
arr[i].balance=balance arr[i].balance=balance
} }
let arrNew=[]
for (let i = 0; i < arr.length; i++) {
let sums = 0
for (let j = i + 1; j < arr.length ; j++) {
sums = sums + parseFloat(arr[j].profit)
if (arrNew.length ===0)
arrNew.push({sum: sums, index: i})
else if (arrNew[arrNew.length-1].sum > sums)
arrNew.push({sum: sums, index: i})
}
}
arrNew = _.orderBy(arrNew, ['sum'])
console.log(arr) console.log(arr)
console.log('Balance ->',balance) console.log('Balance ->',balance)
console.log('Max reserve ->',arrNew[0].sum)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment