❯devtools
Code Highlighter & Snapshot
Beautify code snippets with high-fidelity syntax highlighting. Export beautiful macOS-styled image snapshots or copy formatted HTML/Rich Text in seconds.
Display Line Numbers
Preview & Snapshot Box
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example JavaScript function
function greetUser(name = "Developer") {
const currentHour = new Date().getHours();
let greeting = "Hello";
if (currentHour < 12) {
greeting = "Good morning";
} else if (currentHour < 18) {
greeting = "Good afternoon";
} else {
greeting = "Good evening";
}
console.log(greeting + ", " + name + "!");
return { message: greeting, date: new Date() };
}