|
12 | 12 | "const numbers = [1, 2, 2, 3, 4, 4, 5];", |
13 | 13 | "console.log(removeDuplicates(numbers)); // Output: [1, 2, 3, 4, 5]" |
14 | 14 | ], |
15 | | - "tags": ["javascript", "array", "deduplicate", "utility"], |
| 15 | + "tags": [ |
| 16 | + "javascript", |
| 17 | + "array", |
| 18 | + "deduplicate", |
| 19 | + "utility" |
| 20 | + ], |
16 | 21 | "author": "technoph1le" |
17 | 22 | }, |
18 | 23 | { |
|
25 | 30 | "const nestedArray = [1, [2, [3, [4]]]];", |
26 | 31 | "console.log(flattenArray(nestedArray)); // Output: [1, 2, 3, 4]" |
27 | 32 | ], |
28 | | - "tags": ["javascript", "array", "flatten", "utility"], |
| 33 | + "tags": [ |
| 34 | + "javascript", |
| 35 | + "array", |
| 36 | + "flatten", |
| 37 | + "utility" |
| 38 | + ], |
29 | 39 | "author": "technoph1le" |
30 | 40 | } |
31 | 41 | ] |
|
54 | 64 | "console.log(slugify(title)); // Output: 'hello-world-this-is-a-test'", |
55 | 65 | "console.log(slugify(title, \"_\")); // Output: 'hello_world_this_is_a_test'" |
56 | 66 | ], |
57 | | - "tags": ["javascript", "string", "slug", "utility"], |
| 67 | + "tags": [ |
| 68 | + "javascript", |
| 69 | + "string", |
| 70 | + "slug", |
| 71 | + "utility" |
| 72 | + ], |
58 | 73 | "author": "technoph1le" |
59 | 74 | }, |
60 | 75 | { |
|
66 | 81 | "// Usage:", |
67 | 82 | "console.log(capitalize('hello')); // Output: 'Hello'" |
68 | 83 | ], |
69 | | - "tags": ["javascript", "string", "capitalize", "utility"], |
| 84 | + "tags": [ |
| 85 | + "javascript", |
| 86 | + "string", |
| 87 | + "capitalize", |
| 88 | + "utility" |
| 89 | + ], |
70 | 90 | "author": "technoph1le" |
71 | 91 | }, |
72 | 92 | { |
|
78 | 98 | "// Usage:", |
79 | 99 | "console.log(reverseString('hello')); // Output: 'olleh'" |
80 | 100 | ], |
81 | | - "tags": ["javascript", "string", "reverse", "utility"], |
| 101 | + "tags": [ |
| 102 | + "javascript", |
| 103 | + "string", |
| 104 | + "reverse", |
| 105 | + "utility" |
| 106 | + ], |
82 | 107 | "author": "technoph1le" |
83 | 108 | } |
84 | 109 | ] |
|
95 | 120 | "// Usage:", |
96 | 121 | "console.log(formatDate(new Date())); // Output: '2024-12-10'" |
97 | 122 | ], |
98 | | - "tags": ["javascript", "date", "format", "utility"], |
| 123 | + "tags": [ |
| 124 | + "javascript", |
| 125 | + "date", |
| 126 | + "format", |
| 127 | + "utility" |
| 128 | + ], |
99 | 129 | "author": "technoph1le" |
100 | 130 | }, |
101 | 131 | { |
|
112 | 142 | "const date2 = new Date('2024-12-31');", |
113 | 143 | "console.log(getTimeDifference(date1, date2)); // Output: 365" |
114 | 144 | ], |
115 | | - "tags": ["javascript", "date", "time-difference", "utility"], |
| 145 | + "tags": [ |
| 146 | + "javascript", |
| 147 | + "date", |
| 148 | + "time-difference", |
| 149 | + "utility" |
| 150 | + ], |
116 | 151 | "author": "technoph1le" |
117 | 152 | }, |
118 | 153 | { |
|
177 | 212 | "const randomFunction = () => console.log('Function called!');", |
178 | 213 | "times(randomFunction, 3); // Logs 'Function called!' three times" |
179 | 214 | ], |
180 | | - "tags": ["javascript", "function", "repeat", "utility"], |
| 215 | + "tags": [ |
| 216 | + "javascript", |
| 217 | + "function", |
| 218 | + "repeat", |
| 219 | + "utility" |
| 220 | + ], |
181 | 221 | "author": "technoph1le" |
182 | 222 | }, |
183 | 223 | { |
|
195 | 235 | "// Usage:", |
196 | 236 | "window.addEventListener('resize', debounce(() => console.log('Resized!'), 500));" |
197 | 237 | ], |
198 | | - "tags": ["javascript", "utility", "debounce", "performance"], |
| 238 | + "tags": [ |
| 239 | + "javascript", |
| 240 | + "utility", |
| 241 | + "debounce", |
| 242 | + "performance" |
| 243 | + ], |
199 | 244 | "author": "technoph1le" |
200 | 245 | }, |
201 | 246 | { |
|
225 | 270 | "// Usage:", |
226 | 271 | "document.addEventListener('scroll', throttle(() => console.log('Scrolled!'), 1000));" |
227 | 272 | ], |
228 | | - "tags": ["javascript", "utility", "throttle", "performance"], |
| 273 | + "tags": [ |
| 274 | + "javascript", |
| 275 | + "utility", |
| 276 | + "throttle", |
| 277 | + "performance" |
| 278 | + ], |
229 | 279 | "author": "technoph1le" |
| 280 | + }, |
| 281 | + { |
| 282 | + "title": "Generate Random Color Hex Value", |
| 283 | + "description": "Generates a random hexadecimal color value for use in web design or styling.", |
| 284 | + "code": [ |
| 285 | + "const generateRandomHexColor = () => {", |
| 286 | + " const chars = '0123456789abcdef';", |
| 287 | + " let hex = '#';", |
| 288 | + " for (let i = 0; i < 6; i++) {", |
| 289 | + " hex += chars[Math.floor(Math.random() * chars.length)].toUpperCase();", |
| 290 | + " }", |
| 291 | + " return hex;", |
| 292 | + "};", |
| 293 | + "", |
| 294 | + "// Usage:", |
| 295 | + "console.log(generateRandomHexColor()); // Example output: '#1A2B3C'" |
| 296 | + ], |
| 297 | + "tags": [ |
| 298 | + "javascript", |
| 299 | + "utility", |
| 300 | + "random", |
| 301 | + "hexadecimal", |
| 302 | + "color" |
| 303 | + ], |
| 304 | + "author": "vnikolaew" |
230 | 305 | } |
231 | 306 | ] |
232 | 307 | }, |
|
245 | 320 | "const element = document.querySelector('.my-element');", |
246 | 321 | "toggleClass(element, 'active');" |
247 | 322 | ], |
248 | | - "tags": ["javascript", "dom", "class", "utility"], |
| 323 | + "tags": [ |
| 324 | + "javascript", |
| 325 | + "dom", |
| 326 | + "class", |
| 327 | + "utility" |
| 328 | + ], |
249 | 329 | "author": "technoph1le" |
250 | 330 | }, |
251 | 331 | { |
|
260 | 340 | "const target = document.querySelector('#target');", |
261 | 341 | "smoothScroll(target);" |
262 | 342 | ], |
263 | | - "tags": ["javascript", "dom", "scroll", "ui"], |
| 343 | + "tags": [ |
| 344 | + "javascript", |
| 345 | + "dom", |
| 346 | + "scroll", |
| 347 | + "ui" |
| 348 | + ], |
264 | 349 | "author": "technoph1le" |
265 | 350 | } |
266 | 351 | ] |
|
279 | 364 | "// Usage:", |
280 | 365 | "addToLocalStorage('user', { name: 'John', age: 30 });" |
281 | 366 | ], |
282 | | - "tags": ["javascript", "localStorage", "storage", "utility"], |
| 367 | + "tags": [ |
| 368 | + "javascript", |
| 369 | + "localStorage", |
| 370 | + "storage", |
| 371 | + "utility" |
| 372 | + ], |
283 | 373 | "author": "technoph1le" |
284 | 374 | }, |
285 | 375 | { |
|
295 | 385 | "const user = getFromLocalStorage('user');", |
296 | 386 | "console.log(user); // Output: { name: 'John', age: 30 }" |
297 | 387 | ], |
298 | | - "tags": ["javascript", "localStorage", "storage", "utility"], |
| 388 | + "tags": [ |
| 389 | + "javascript", |
| 390 | + "localStorage", |
| 391 | + "storage", |
| 392 | + "utility" |
| 393 | + ], |
299 | 394 | "author": "technoph1le" |
300 | 395 | }, |
301 | 396 | { |
|
309 | 404 | "// Usage:", |
310 | 405 | "clearLocalStorage(); // Removes all items from localStorage" |
311 | 406 | ], |
312 | | - "tags": ["javascript", "localStorage", "storage", "utility"], |
| 407 | + "tags": [ |
| 408 | + "javascript", |
| 409 | + "localStorage", |
| 410 | + "storage", |
| 411 | + "utility" |
| 412 | + ], |
313 | 413 | "author": "technoph1le" |
314 | 414 | } |
315 | 415 | ] |
|
0 commit comments