# JavaScript Function to get point on line where two points are known function point line of code,point function line,function point

Given two points:

``````const point1 = {x: 100, y: 0.95}
const point2 = {x: 75, y: 1.05}
``````

I need to know the value of y when x equals some arbitrary value.

Please assume a linear relationship exists.

For example, what is y when x is 80? what is y when x is 70?

Is there a function that I could use for this?

Currently I've been confused by mathematical explanations and would ideally like a JavaScript or jQuery function that, when given an arbitrary x value returns the y value.

Sure, the `gradient` of a line is the amount `y` increases for every unit `x` increases. E.g. if `y` goes up 5 for every 2 `x` goes up, the line is said to have a gradient of 2.5.

The gradient can be calculated from 2 points like so:

``````var gradient = (point2.y - point1.y) / (point2.x - point1.x);
``````

The intercept of a line is the `y` value it crosses the `y` axis at. It can be calculated from 1 point like so:

``````var intercept = point1.y - (gradient * point1.x);
``````

The `y` value for any `x` value can then be calculated:

``````var x = 10;
var y = gradient * x + intercept;
``````

A function which combines these things might look like:

``````function yFromX(point1, point2, x) {
var gradient = (point2.y - point1.y) / (point2.x - point1.x);
var intercept = point1.y - (gradient * point1.x);
return gradient * x + intercept;
}
``````
``````const point1 = {x: 100, y: 0.95}
const point2 = {x: 75, y: 1.05}

function getY (x) {
var gradient = (point1.y - point2.y)/(point1.x - point2.x);
return point1.y + gradient * (x - point1.x);
}

``````

## Use of knockoutjs disable binding

I am trying to get an input box to be disabled when a checkbox is checked. I'm trying to use Knockoutjs to get this done, but it doesn't seem to work. Here is my html: <input id="input1" type="...

I am trying to get an input box to be disabled when a checkbox is checked. I'm trying to use Knockoutjs to get this done, but it doesn't seem to work. Here is my html: <input id="input1" type="...

1. knockout js disabled binding
2. knockout js disable binding

## Programmatically send keys to input using dispatchEvent

I'm trying to send characters to an input element based on user actions. I'm trying to use KeyboardEvent with dispatchEvent but whatever I do, it doesn't work For example: let keyEvent = new ...

I'm trying to send characters to an input element based on user actions. I'm trying to use KeyboardEvent with dispatchEvent but whatever I do, it doesn't work For example: let keyEvent = new ...

## find all word start with specific character followed by digits in string

I want to find all word which start with mc and followed by all digits only var myString="hi mc1001 hello mc1002 mc1003 mc1004 mc mca" Require output = [ mc1001,mc1002,mc1003,mc1004] My solution: ...

I want to find all word which start with mc and followed by all digits only var myString="hi mc1001 hello mc1002 mc1003 mc1004 mc mca" Require output = [ mc1001,mc1002,mc1003,mc1004] My solution: ...

2. how to find word startup folder
12. find word starting with regex
13. find word starting with python
14. find word starting with x
15. find word starting with hash
16. find word starting with k
17. find word starting with play
18. word find start of line