//JS там есть 2 комментария
var button1 = document.getElementById(“buttonPlus”);
button1.onclick = f1;
var button2 = document.getElementById("buttonSubtract");
button2.onclick = f2;
var button3 = document.getElementById("buttonMultiply");
button3.onclick = f3;
var button4 = document.getElementById("buttonDivide");
button4.onclick = f4;
var button5 = document.getElementById("buttonPow");
button5.onclick = f5;
var button6 = document.getElementById("buttonSquareRoot");
button6.onclick = f6;
var button7 = document.getElementById("plusInput");
button7.onclick = f7;
var third = document.getElementById("third");
var fourth = document.getElementById("fourth");
var fifth = document.getElementById("fifth");
function f7() {
var question = prompt("Сколько добавить, максимум 3");
if (question == 1) {
third.className = "no";
}
if (question == 2) {
third.className = "no";
fourth.className = "no";
}
if (question == 3) {
third.className = "no";
fourth.className = "no";
fifth.className = "no";
}
else {
third.className = "no";
}
}
function f1() {
var third = document.getElementById("third").value;
third = parseInt(third);
var fourth = document.getElementById("fourth").value;
fourth = parseInt(fourth);
var fifth = document.getElementById("fifth").value;
fifth = parseInt(fifth);
var first = document.getElementById("first").value;
first = parseInt(first);
var second = document.getElementById("second").value;
second = parseInt(second);
var results = +first + +second + third + fourth + fifth;
// Тут все нормально, т.к value = 0
var Text = document.getElementById("test");
Text.innerHTML = results;
}
function f2() {
var third = document.getElementById("third").value;
third = parseInt(third);
var fourth = document.getElementById("fourth").value;
fourth = parseInt(fourth);
var fifth = document.getElementById("fifth").value;
fifth = parseInt(fifth);
var first = document.getElementById("first").value;
first = parseInt(first);
var second = document.getElementById("second").value;
second = parseInt(second);
var Text = document.getElementById("test");
var results = first - second - third - fourth - fifth;
Text.innerHTML = results;
}
function f3() {
var third = document.getElementById("third");
third = parseInt(third);
var fourth = document.getElementById("fourth");
fourth = parseInt(fourth);
var fifth = document.getElementById("fifth");
fifth = parseInt(fifth);
var first = document.getElementById("first").value;
first = parseInt(first);
var second = document.getElementById("second").value;
second = parseInt(second);
var Text = document.getElementById("test");
var results = first * second;
// а тут так не получится, т.к умножаем на 0
Text.innerHTML = results;
}
function f4() {
var first = document.getElementById("first").value;
first = parseInt(first);
var second = document.getElementById("second").value;
second = parseInt(second);
var Text = document.getElementById("test");
var results = first/second;
Text.innerHTML = results;
}
function f5() {
var first = document.getElementById("first").value;
first = parseInt(first);
var second = document.getElementById("second").value;
second = parseInt(second);
var Text = document.getElementById("test");
var results = Math.pow(first, second);
Text.innerHTML = results;
}
function f6() {
var first = document.getElementById("first").value;
first = parseInt(first);
var Text = document.getElementById("test");
var results = Math.sqrt(first);
Text.innerHTML = parseFloat(results.toFixed(2));
}`Текст "как есть" (без применения форматирования)`
// HTML
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<title>for sort split</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>for sort split</h1>
<input type="text" id = "first" placeholder="Первое число">
<input type="text" id = "second" placeholder="Второе">
<button id="plusInput">+</button>
<input type="text" id = "third" class="none" value ="0" placeholder="Третье">
<input type="text" id = "fourth" class="none" value ="0" placeholder="Четвертое">
<input type="text" id = "fifth" class="none" value ="0" placeholder="Пятое">
<br>
<button type = "button" id="buttonPlus">+</button>
<button type = "button" id="buttonSubtract">-</button>
<button type = "button" id="buttonMultiply">*</button>
<button type = "button" id="buttonDivide">/</button>
<button type = "button" id="buttonPow">^</button>
<button type = "button" id="buttonSquareRoot">√</button>
<br>
<div id="test"></div>
<script src="script.js"></script>
</body>
</html>