Square Pattern - The numbers 0 and 1 are staggered - HTML CSS JS
Result:
Code: HTML + CSS + JavaScript
<!--
ThinhPham YouTube Channel
youtube.com/@thinhphamvn
tpvncode.blogspot.com
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>
The numbers 0 and 1 are staggered
</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #000c18;
color: greenyellow;
text-shadow: 0px 0px 8px greenyellow;
font-size: 30px;
font-weight: bold;
}
</style>
</head>
<body>
<script>
let n = 9;
let string = "";
for (let i = 1; i <= n; i++) {
for (let j = 1; j <= n; j++) {
string += ((i + j) % 2 === 0) ? "0 " : "1 ";
}
string += "<br>";
}
document.write(`<pre>${string}</pre>`);
</script>
</body>
</html>