Recall the linear equation: y = mx + b Complete the missing code as noted by the
ID: 3940784 • Letter: R
Question
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 */Explanation / Answer
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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.