I've got this formula: L=P (N^2 + N ) / 1.25 + 0.7 x F
I need to write it in Javascript, I've got general error checking code, then I get to the point of calculating the inductance.
var N = parseFloat($("#Number").val());
var P = parseFloat($("#Perimeter").val());
var F = parseFloat($("#Feeder").val());
var L = P (Math.pow(N,2) + N) / 1.25 + 0.7 * F
$("#result").html(L);
I tested just adding the variables to start, now I added the formu开发者_StackOverflow社区la in, but no result shows.
You're missing a *
here:
var L = P (Math.pow(N,2) + N) / 1.25 + 0.7 * F
Try:
var L = P * (Math.pow(N,2) + N) / 1.25 + 0.7 * F
You need an operator after P
:
var L = P * (Math.pow(N,2) + N) / 1.25 + 0.7 * F
I'm not sure about the proper order here (it's been a while since Phys II), so you may want to add some parentheses to be sure the operations happen in the order they should.
You are missing a *
here without which javascript is treating P (Math.pow(N,2) + N)
as a call to a function P
with parameter as Math.pow(N,2) + N
Try this:
var L = P * (Math.pow(N,2) + N) / 1.25 + 0.7 * F
精彩评论