gpt4 book ai didi

Javascript三 Angular 形确定

转载 作者:行者123 更新时间:2023-11-30 18:19:13 27 4
gpt4 key购买 nike

我正在用 javascript 编写一个基本程序,如果有人将某个变量输入 3 个输入中的任何一个,它会确定正在制作哪种类型的三 Angular 形。

<html>
<head>
<link href="stylesheet/stylesheet.css" rel="stylesheet" type="text/css">

<script language="Javascript" type="text/javascript">

/* Key/Legend
Var
inp1 = input1
inp2 = input2
inp3 = input3
Triangle_Inputs = Form Name

*/

/* Notes

In computing, a parser is one of the components in an interpreter or
compiler that checks for correct syntax and builds a data structure
(often some kind of parse tree, abstract syntax tree or other hierarchical structure)
implicit in the input tokens.


Technique
if (side1 is equal to side2 AND side 2 is equal to side3) {equalitateral}

if (side1 is equal to side2 AND side 2 doesn't equal to side3) {isosceles}

if (side1 doesn't equal to side2 AND side2 doesn't equal to side 3 AND side 3 doesn't equal side 1) {scalene}

http://www.w3schools.com/js/js_comparisons.asp

*/


function checkinputs()
{
/* Var = parseInt(document.Name_Of_Element_Form.Field_Name(Input).value); */
/* Input Fields */
inp1 = parseInt(document.Triangle_Inputs.input1.value);
inp2 = parseInt(document.Triangle_Inputs.input2.value);
inp3 = parseInt(document.Triangle_Inputs.input3.value);
/* Side options */
sideA = (inp1 + inp2);
sideB = (inp1 + inp3);
sideC = (inp2 + inp3);
if (sideA == sideB && sideB == sideC) {
alert("Equalateral");
}
if (sideA == sideB && != sideC) {
alert("Isosceles");
}
if (sideA != sideB == sideC) {
alert("Isosceles");
}
if (sideA != sideB != sideC != sideA) {
alert("Scalene!");
}
}
</script>


</head>
<body>
<div id="Container">

<div id="Header"><h1></h1></div>

<div id="Content_1">
<div id="Explanation">
This calculator will determine what
triangle you have made depending on
the integer values in the input fields.

</div>
<div id="Form">
<FORM NAME="Triangle_Inputs" METHOD="GET">
Enter the triangle values below: <br>
<p>
<h4>Side 1: </h4><BR>
<INPUT TYPE="Integer" NAME="input1" VALUE=""><P>
<h4>Side 2: </h4><BR>
<INPUT TYPE="Integer" NAME="input2" VALUE=""><P>
<h4>Side 3:</h4> <BR>
<INPUT TYPE="Integer" NAME="input3" VALUE=""><P>
<INPUT TYPE="button" NAME="Submit" Value="Submit" Class="Submit" onClick="checkinputs()">
</FORM>
</div>
<div id="Verbal_Output">
<h2>You made a:</h2>
<p>
<h2>Triangle</h2>
</div>

</div>
<p>
<p>
<div id="Content_2">

<div id="Image_Output">asdad</div>
</div>
</div>



</body>
</html>

但是我认为我遗漏了一些东西,我似乎无法收到通知来告诉用户任何事情。

谢谢大家,很抱歉提出这个问题,这让我很困惑

最佳答案

试试这个函数:

function getTriangleType(a,b,c) {
return (a === b && b === c) && 'equilateral' ||
(a === b || a === c || b === c) && 'isosceles' ||
'scalene';
}

演示: http://jsbin.com/eyoxor/3/edit

关于Javascript三 Angular 形确定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12491976/

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