Created
November 22, 2023 08:59
-
-
Save Steiden/a2b8d2938f0ad270ecfe252d1a9fd06b to your computer and use it in GitHub Desktop.
круио
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div> | |
<input type="text" id="adress1"> | |
<button id="submit" type="submit">Отправить</button> | |
</div> | |
<img src="./photo_2023-11-22_13-05-45.jpg" width="500" alt=""> | |
<img src="./photo_2023-11-22_13-51-54.jpg" width="500" alt=""> | |
<script src="./script.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input1 = document.getElementById("adress1"); | |
button = document.getElementById("submit"); | |
const arr = [128, 64, 32, 16, 8, 4, 2, 1]; | |
button.addEventListener("click", function () { | |
// получение адресов | |
let num = input1.value; | |
let res = ''; | |
for(let i = 0; i < arr.length; i++) { | |
if(num - arr[i] >= 0) { | |
res += '1'; | |
num -= arr[i]; | |
} else { | |
res += '0'; | |
continue; | |
} | |
} | |
alert(res); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
default.mp4