Georgie0409,
const myPos = {x: 2000, y: 1000, z: 500},
otherPosition = [
{x: 2500, y: 1200, z: 600},
{x: 2300, y: 1200, z: 490},
{x: 2150, y: 1400, z: 400}
], index = otherPosition.reduce(({min, index}, {x,y,z}, i) => {
const temp = Math.hypot(myPos.x-x,myPos.y-y,myPos.z-z)
if(temp < min) {min = temp, index = i};
return {min, index}
}, {min : Number.POSITIVE_INFINITY}).index;
alert(index);