create a blue square and center it in the screen and make its size medium and whenever you click it make an alert saying "you clicked the square" in javascript

You can create a blue square and center it in the screen using the following HTML and CSS code:

<div id="blue-square"></div>
29 chars
2 lines
#blue-square {
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   background-color: blue;
   width: 200px;
   height: 200px;
}
166 chars
10 lines

To add an event listener to the square and create an alert message when clicked, you can use the following JavaScript code:

index.tsx
const blueSquare = document.getElementById('blue-square');

blueSquare.addEventListener('click', () => {
  alert("you clicked the square");
});
144 chars
6 lines

This will create a blue square and center it in the middle of the screen. When you click on it, it will display an alert message saying "you clicked the square".

gistlibby LogSnag