Linear interpolation

Using linear interpolation, given any two points

(x0, y0) and (x1, y1)

and the value x2,where x0≤x2 ≤x1

the corresponding y2 value is given by

y2 = y0 + (y1-y0) / (x1-x0) * (x2-x0)
 var x0 = 1; var x1 = 20; var y0 = 30; var y1 = 35; var arr = new Array(); for (i=1;i<=20;i++){ y2 = y0 + (y1-y0) / (x1-x0) * (i-x0) arr[i] = i+' ...... '+y2; }