gpt4 book ai didi

javascript - 基本 JScalc.io 计算器问题(输出变量为空,不返回数字)

转载 作者:行者123 更新时间:2023-11-28 06:09:30 25 4
gpt4 key购买 nike

我正在通过jscalc.io制作一个 super 基本的JS计算器

我的变量遇到问题。这是 a link to my calculator

问题出在右下角的“GSD”输出。我没有收到任何语法错误,但 GSD 不会输出数字...它只是空白?是因为我试图使用输出而不是输入来创建函数吗?

希望有人能给指导一下。

以下是相关代码,其中包含我的 GSD 输出变量的公式:

'use strict';
var meters = inputs.W * inputs.L
;var kilometers = meters * 0.000001
;var acres = meters * 0.000247105
;var hectares = meters * 0.0001
;var miles = acres * 0.0015625
;var H = H
;var GSD = (Sw * H * 100) / (Fr * imW);

//GSD = (Sw * H * 100) / (Fr * imW)

// DRONE CAMERA TYPE SETTINGS RESOLUTION
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'P3I1'){
imW = 4000;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'P3I1'){
imH = 3000;
}
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'I1P'){
imW = 4608;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'I1P'){
imH = 3456;
}
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'CS100'){
imW = 4000;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'CS100'){
imH = 3000;
}

// DRONE CAMERA TYPE SETTINGS FOCAL LENGTH
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'P3I1'){
Fr = 3.61;
}
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'I1P'){
Fr = 15;
}
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'CS100'){
Fr = 5.2;
}

// DRONE CAMERA TYPE SETTINGS PIXEL PITCH
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'P3I1'){
PP = 1.56;
}
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'I1P'){
PP = 4.8;
}
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'CS100'){
PP = 3.4;
}

// DRONE CAMERA TYPE SETTINGS SENSOR WIDTH
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'P3I1'){
Sw = 6.24;
}
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'I1P'){
Sw = 22.12;
}
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'CS100'){
Sw = 13.6;
}

return {
meters: meters,
kilometers: kilometers,
acres: acres,
hectares: hectares,
miles: miles,
imW: imW,
imH: imH,
Fr: Fr,
PP: PP,
Sw: Sw,
GSD: GSD,
// imH: imH
};

感谢您的浏览!

最佳答案

问题出在 var H = H 行,这应该是 var H = input.H

关于javascript - 基本 JScalc.io 计算器问题(输出变量为空,不返回数字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36534831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com