Skip to content

Instantly share code, notes, and snippets.

@Steiden
Created November 22, 2023 08:59
Show Gist options
  • Save Steiden/a2b8d2938f0ad270ecfe252d1a9fd06b to your computer and use it in GitHub Desktop.
Save Steiden/a2b8d2938f0ad270ecfe252d1a9fd06b to your computer and use it in GitHub Desktop.
круио
<!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>
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);
})
@Abragadabra
Copy link

default.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment