gpt4 book ai didi

javascript(+)符号连接而不是给出总和?

转载 作者:搜寻专家 更新时间:2023-10-31 21:56:25 26 4
gpt4 key购买 nike

<分区>

我创建了一个简单的程序来计算两个数字的总和但是..该程序改为连接,这太令人困惑了!谁能帮忙?

function calculate() {
var numberOne = document.querySelector(".first").value;
var numberTwo = document.querySelector(".second").value;
var sum = numberOne + numberTwo;
document.querySelector(".result").innerHTML = "The sum of the two numbers is : " + sum;
}
<!doctype html>
<html>

<body>
<p>Calculate sum of two numbers !</p>
Enter 1rst Number:<br>
<input type="number" class="first" placeholder=""><br><br> Enter 2nd Number:<br>
<input type="number" class="second" placeholder=""><br><br>
<input type="button" onclick="calculate()" value="calculate">
<p class="result"></p>
</body>

</html>

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