Slope function error(sort-of)… again [closed]

Why don’t you check the direction before you do your calculations? Something like:

function slope(x1,y1,x2,y2,ex,direction){

    if(direction == "right"){
      var gg1 = x2-x1;
      var gg2 = y2-y1;
      var ggs = gg2/gg1;
      var ggsR = gg1/gg2;
      console.log(ggsR);
      return(ggs);
    }
    else if(direction == "left"){
      //do something else
    }
};

Leave a Comment