Recall the linear equation y mx b Complete the missing cod

Recall the linear equation: y = mx + b Complete the missing code as noted by the underlined areas () for the \"linearEquation\" function. The code should: Calculate the y value given the slope, x and b values. - The slope, m, is calculated as mY divided by mX Return the calculated value. Put the computed value in the input: /* Complete all the missing lines e.g. () */var mX = 2; var mY = 4; var b = 1; var x = 1; function linearEquation (mY, mX, b, ) {} var valA = linearEquation ();/* Set the computed value as required in 2. below */

Solution

Hi,

As given in the question we will calculate slope inside function and we will multiply with value and add b.

In the first line of function definition x is missing so we filled the dash with x and inside we calcultaed m and directly returning the value of y.

function linearEquation(mY,mX,b,x){

var m= mY/mX;

return (m*x)+b;

}

so when we call the function in the line :: var valA = linearEquation(mY,mX,b,x); we should pass the values to the function

and the last part add the return value to input tag will be by adding the below line after calling the function:

this the command in java script to fetch a item by its id and we will set a value to it. The id of the input tag is already given in the question as lineResult and the value will be returned by function and saved in valA.

Thank you and please comment below if you want any further clarification

 Recall the linear equation: y = mx + b Complete the missing code as noted by the underlined areas () for the \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site