Skip to content

Instantly share code, notes, and snippets.

@otknoy
Created October 30, 2015 15:23
Show Gist options
  • Save otknoy/e511662378982e2dd6b0 to your computer and use it in GitHub Desktop.
Save otknoy/e511662378982e2dd6b0 to your computer and use it in GitHub Desktop.
var data = [1, 3, 3, 4, 5, 3, 1];
function changeOfPosition(data) {
var d = Array(data.length - 1);
for (var i = 0; i < d.length; i++) {
d[i] = data[i+1] - data[i];
}
return d;
}
console.log(data);
console.log(changeOfPosition(data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment