<script> var x = 5, y = 5, x2 = 2, y2 = -10; var time = Math.abs(x - x2); for (var i=0; i<=time; i++) { var delta = i/time ; var a = delta*(x2 - x) + x; var b = delta*(y2 - y) + y; document.write([a,b]+"<br>") } </script>