Skip to content

Commit 8a69036

Browse files
committed
feat(app): Adding a function for generating random hex color values.
1 parent 655bbd8 commit 8a69036

File tree

1 file changed

+115
-15
lines changed

1 file changed

+115
-15
lines changed

public/data/javascript.json

Lines changed: 115 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"const numbers = [1, 2, 2, 3, 4, 4, 5];",
1313
"console.log(removeDuplicates(numbers)); // Output: [1, 2, 3, 4, 5]"
1414
],
15-
"tags": ["javascript", "array", "deduplicate", "utility"],
15+
"tags": [
16+
"javascript",
17+
"array",
18+
"deduplicate",
19+
"utility"
20+
],
1621
"author": "technoph1le"
1722
},
1823
{
@@ -25,7 +30,12 @@
2530
"const nestedArray = [1, [2, [3, [4]]]];",
2631
"console.log(flattenArray(nestedArray)); // Output: [1, 2, 3, 4]"
2732
],
28-
"tags": ["javascript", "array", "flatten", "utility"],
33+
"tags": [
34+
"javascript",
35+
"array",
36+
"flatten",
37+
"utility"
38+
],
2939
"author": "technoph1le"
3040
}
3141
]
@@ -54,7 +64,12 @@
5464
"console.log(slugify(title)); // Output: 'hello-world-this-is-a-test'",
5565
"console.log(slugify(title, \"_\")); // Output: 'hello_world_this_is_a_test'"
5666
],
57-
"tags": ["javascript", "string", "slug", "utility"],
67+
"tags": [
68+
"javascript",
69+
"string",
70+
"slug",
71+
"utility"
72+
],
5873
"author": "technoph1le"
5974
},
6075
{
@@ -66,7 +81,12 @@
6681
"// Usage:",
6782
"console.log(capitalize('hello')); // Output: 'Hello'"
6883
],
69-
"tags": ["javascript", "string", "capitalize", "utility"],
84+
"tags": [
85+
"javascript",
86+
"string",
87+
"capitalize",
88+
"utility"
89+
],
7090
"author": "technoph1le"
7191
},
7292
{
@@ -78,7 +98,12 @@
7898
"// Usage:",
7999
"console.log(reverseString('hello')); // Output: 'olleh'"
80100
],
81-
"tags": ["javascript", "string", "reverse", "utility"],
101+
"tags": [
102+
"javascript",
103+
"string",
104+
"reverse",
105+
"utility"
106+
],
82107
"author": "technoph1le"
83108
}
84109
]
@@ -95,7 +120,12 @@
95120
"// Usage:",
96121
"console.log(formatDate(new Date())); // Output: '2024-12-10'"
97122
],
98-
"tags": ["javascript", "date", "format", "utility"],
123+
"tags": [
124+
"javascript",
125+
"date",
126+
"format",
127+
"utility"
128+
],
99129
"author": "technoph1le"
100130
},
101131
{
@@ -112,7 +142,12 @@
112142
"const date2 = new Date('2024-12-31');",
113143
"console.log(getTimeDifference(date1, date2)); // Output: 365"
114144
],
115-
"tags": ["javascript", "date", "time-difference", "utility"],
145+
"tags": [
146+
"javascript",
147+
"date",
148+
"time-difference",
149+
"utility"
150+
],
116151
"author": "technoph1le"
117152
},
118153
{
@@ -177,7 +212,12 @@
177212
"const randomFunction = () => console.log('Function called!');",
178213
"times(randomFunction, 3); // Logs 'Function called!' three times"
179214
],
180-
"tags": ["javascript", "function", "repeat", "utility"],
215+
"tags": [
216+
"javascript",
217+
"function",
218+
"repeat",
219+
"utility"
220+
],
181221
"author": "technoph1le"
182222
},
183223
{
@@ -195,7 +235,12 @@
195235
"// Usage:",
196236
"window.addEventListener('resize', debounce(() => console.log('Resized!'), 500));"
197237
],
198-
"tags": ["javascript", "utility", "debounce", "performance"],
238+
"tags": [
239+
"javascript",
240+
"utility",
241+
"debounce",
242+
"performance"
243+
],
199244
"author": "technoph1le"
200245
},
201246
{
@@ -225,8 +270,38 @@
225270
"// Usage:",
226271
"document.addEventListener('scroll', throttle(() => console.log('Scrolled!'), 1000));"
227272
],
228-
"tags": ["javascript", "utility", "throttle", "performance"],
273+
"tags": [
274+
"javascript",
275+
"utility",
276+
"throttle",
277+
"performance"
278+
],
229279
"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"
230305
}
231306
]
232307
},
@@ -245,7 +320,12 @@
245320
"const element = document.querySelector('.my-element');",
246321
"toggleClass(element, 'active');"
247322
],
248-
"tags": ["javascript", "dom", "class", "utility"],
323+
"tags": [
324+
"javascript",
325+
"dom",
326+
"class",
327+
"utility"
328+
],
249329
"author": "technoph1le"
250330
},
251331
{
@@ -260,7 +340,12 @@
260340
"const target = document.querySelector('#target');",
261341
"smoothScroll(target);"
262342
],
263-
"tags": ["javascript", "dom", "scroll", "ui"],
343+
"tags": [
344+
"javascript",
345+
"dom",
346+
"scroll",
347+
"ui"
348+
],
264349
"author": "technoph1le"
265350
}
266351
]
@@ -279,7 +364,12 @@
279364
"// Usage:",
280365
"addToLocalStorage('user', { name: 'John', age: 30 });"
281366
],
282-
"tags": ["javascript", "localStorage", "storage", "utility"],
367+
"tags": [
368+
"javascript",
369+
"localStorage",
370+
"storage",
371+
"utility"
372+
],
283373
"author": "technoph1le"
284374
},
285375
{
@@ -295,7 +385,12 @@
295385
"const user = getFromLocalStorage('user');",
296386
"console.log(user); // Output: { name: 'John', age: 30 }"
297387
],
298-
"tags": ["javascript", "localStorage", "storage", "utility"],
388+
"tags": [
389+
"javascript",
390+
"localStorage",
391+
"storage",
392+
"utility"
393+
],
299394
"author": "technoph1le"
300395
},
301396
{
@@ -309,7 +404,12 @@
309404
"// Usage:",
310405
"clearLocalStorage(); // Removes all items from localStorage"
311406
],
312-
"tags": ["javascript", "localStorage", "storage", "utility"],
407+
"tags": [
408+
"javascript",
409+
"localStorage",
410+
"storage",
411+
"utility"
412+
],
313413
"author": "technoph1le"
314414
}
315415
]

0 commit comments

Comments
 (0)