Skip to content

Commit a00df69

Browse files
committed
refactor: Added javascript tag to some javascript snippets for more consistency
1 parent d09d412 commit a00df69

File tree

1 file changed

+30
-39
lines changed

1 file changed

+30
-39
lines changed

public/data/javascript.json

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
"// Example usage:",
169169
"console.log(countWords('Hello world! This is a test.')); // Output: 6"
170170
],
171-
"tags": ["string", "manipulation", "word count", "count"],
171+
"tags": ["javascript", "string", "manipulation", "word count", "count"],
172172
"author": "axorax"
173173
},
174174
{
@@ -182,7 +182,7 @@
182182
"// Example usage:",
183183
"console.log(removeWhitespace('Hello world!')); // Output: 'Helloworld!'"
184184
],
185-
"tags": ["string", "whitespace"],
185+
"tags": ["javascript", "string", "whitespace"],
186186
"author": "axorax"
187187
}
188188
]
@@ -318,15 +318,7 @@
318318
"console.log(timeAgoOrAhead(new Date())); // just now",
319319
"console.log(timeAgoOrAhead(futureDate)); // in x years"
320320
],
321-
"tags": [
322-
"javascript",
323-
"date",
324-
"time",
325-
"relative",
326-
"future",
327-
"past",
328-
"utility"
329-
],
321+
"tags": ["javascript", "date", "time", "relative", "future", "past", "utility"],
330322
"author": "Yugveer06"
331323
}
332324
]
@@ -529,32 +521,31 @@
529521
}
530522
]
531523
},
532-
{
533-
"categoryName": "Number Formatting",
534-
"snippets": [
535-
{
536-
"title": "Number Formatter",
537-
"description": "Formats a number with suffixes (K, M, B, etc.).",
538-
"code": [
539-
"const nFormatter = (num) => {",
540-
" if (!num) return;",
541-
" num = parseFloat(num.toString().replace(/[^0-9.]/g, ''));",
542-
" const suffixes = ['', 'K', 'M', 'B', 'T', 'P', 'E'];",
543-
" let index = 0;",
544-
" while (num >= 1000 && index < suffixes.length - 1) {",
545-
" num /= 1000;",
546-
" index++;",
547-
" }",
548-
" return num.toFixed(2).replace(/\\.0+$|(\\.[0-9]*[1-9])0+$/, '$1') + suffixes[index];",
549-
"};",
550-
"",
551-
"// Usage:",
552-
"console.log(nFormatter(1234567)); // Output: '1.23M'"
553-
],
554-
"tags": ["javascript", "number", "format", "utility"],
555-
"author": "realvishalrana"
556-
}
557-
]
558-
}
559-
524+
{
525+
"categoryName": "Number Formatting",
526+
"snippets": [
527+
{
528+
"title": "Number Formatter",
529+
"description": "Formats a number with suffixes (K, M, B, etc.).",
530+
"code": [
531+
"const nFormatter = (num) => {",
532+
" if (!num) return;",
533+
" num = parseFloat(num.toString().replace(/[^0-9.]/g, ''));",
534+
" const suffixes = ['', 'K', 'M', 'B', 'T', 'P', 'E'];",
535+
" let index = 0;",
536+
" while (num >= 1000 && index < suffixes.length - 1) {",
537+
" num /= 1000;",
538+
" index++;",
539+
" }",
540+
" return num.toFixed(2).replace(/\\.0+$|(\\.[0-9]*[1-9])0+$/, '$1') + suffixes[index];",
541+
"};",
542+
"",
543+
"// Usage:",
544+
"console.log(nFormatter(1234567)); // Output: '1.23M'"
545+
],
546+
"tags": ["javascript", "number", "format", "utility"],
547+
"author": "realvishalrana"
548+
}
549+
]
550+
}
560551
]

0 commit comments

Comments
 (0)