✨ Create a Code Snippet


My Code Snippets

Display an Image in HTML
html
<img src="image.jpg" alt="My Image" />
Declare a Variable in TypeScript
typescript
let message: string = "Hello";
Create a Button in HTML
html
<button type="button">
	Click Me
</button>
Define a Function in TypeScript
typescript
function greet(name: string): string {
	return "Hello! " + name;
}
Add a CSS Style in HTML
html
<style>
	body {
		background-color: #f0f0f0;
	}
</style>
Use a Conditional Statement in TypeScript
typescript
if (age >= 18) {
	console.log("You are an adult");
}
Create a List in HTML
html
<ul>
	<li>Item 1</li>
	<li>Item 2</li>
</ul>
Loop through an Array in TypeScript
typescript
const numbers: number[] = [1, 2, 3];

for (const num of numbers) {
	console.log(num);
}
Get User Input in HTML
html
<input type="text" id="username" placeholder="Enter your name" />
Handle Click Events in TypeScript
typescript
const button = document.getElementById("myButton");

button.addEventListener("click", () => {
	console.log("Button clicked!");
});