Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions public/data/javascript.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,49 @@
],
"tags": ["javascript", "data", "utility"],
"author": "realvishalrana"
},
{
"title": "Check if String is a Palindrome",
"description": "Checks whether a given string is a palindrome.",
"code": [
"function isPalindrome(str) {",
" const cleanStr = str.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();",
" return cleanStr === cleanStr.split('').reverse().join('');",
"}",
"",
"// Example usage:",
"console.log(isPalindrome('A man, a plan, a canal, Panama')); // Output: true"
],
"tags": ["javascript", "check", "palindrome", "string"],
"author": "axorax"
},
{
"title": "Count Words in a String",
"description": "Counts the number of words in a string.",
"code": [
"function countWords(str) {",
" return str.trim().split(/\\s+/).length;",
"}",
"",
"// Example usage:",
"console.log(countWords('Hello world! This is a test.')); // Output: 6"
],
"tags": ["string", "manipulation", "word count", "count"],
"author": "axorax"
},
{
"title": "Remove All Whitespace",
"description": "Removes all whitespace from a string.",
"code": [
"function removeWhitespace(str) {",
" return str.replace(/\\s+/g, '');",
"}",
"",
"// Example usage:",
"console.log(removeWhitespace('Hello world!')); // Output: 'Helloworld!'"
],
"tags": ["string", "whitespace"],
"author": "axorax"
}
]
},
Expand Down