xxxxxxxxxx
// this is a code for one of my projects. This function will allow
// you to find all the differences between each array, sort them and update
// them. just dont copy them, I'm just saving them for later.
const selected = [2,1,7,6,14,11,9].sort((a,b) => a-b)
console.log(selected)
// console.log(selected.sort())
var db = 3 // right_a
const added = []
added.push(db)
const difference = []
for (let i = 0; i < selected.length-1; i++){
difference.push(selected[i+1] - selected[i])
}
for (let i = 0; i < difference.length; i++){
added.push(db += difference[i])
}
console.log(added)