I was wondering how i could achieve the above with the code i have below. So for example, when the data is joined i would have in an index in the new array combinedresults something like [2.62, 460]. Both functions below are called through an event listener when the user clicks a button. Any help would be much appreciated, thanks.
var mouseDistance = new Array();
var timers = new Array();
var combinedresults = new Array();
//THIS FUNCTION CALCULATES THE DISTANCE MOVED
function printMousePos(e) {
var lastSeenAt = {
x: null,
y: null
};
var cursorX = e.clientX;
var cursorY = e.clientY;
var math = Math.round(Math.sqrt(Math.pow(lastSeenAt.y - cursorY, 2) +
Math.pow(lastSeenAt.x - cursorX, 2)));
mouseDistance.push(math);
}
function stopCount() {
clearTimeout(t);
timer_is_on = 0;
timers.push(t);
}
var lastSeenAt = {x: null, y: null};is causing the trouble I guess. Move this out of that function. Otherwise you just try to computeMath.pow(null - somenumer, 2).prevX, prevY, totalTravelledthen, can't see where they're used in your code.