File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 563
563
" utility"
564
564
],
565
565
"author" : " realvishalrana"
566
+ },
567
+ {
568
+ "title" : " Check if String is a Palindrome" ,
569
+ "description" : " Checks whether a given string is a palindrome." ,
570
+ "code" : [
571
+ " function isPalindrome(str) {" ,
572
+ " const cleanStr = str.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();" ,
573
+ " return cleanStr === cleanStr.split('').reverse().join('');" ,
574
+ " }" ,
575
+ " " ,
576
+ " // Example usage:" ,
577
+ " console.log(isPalindrome('A man, a plan, a canal, Panama')); // Output: true"
578
+ ],
579
+ "tags" : [
580
+ " javascript" ,
581
+ " check" ,
582
+ " palindrome" ,
583
+ " string"
584
+ ],
585
+ "author" : " axorax"
586
+ },
587
+ {
588
+ "title" : " Count Words in a String" ,
589
+ "description" : " Counts the number of words in a string." ,
590
+ "code" : [
591
+ " function countWords(str) {" ,
592
+ " return str.trim().split(/\\ s+/).length;" ,
593
+ " }" ,
594
+ " " ,
595
+ " // Example usage:" ,
596
+ " console.log(countWords('Hello world! This is a test.')); // Output: 6"
597
+ ],
598
+ "tags" : [
599
+ " string" ,
600
+ " manipulation" ,
601
+ " word count" ,
602
+ " count"
603
+ ],
604
+ "author" : " axorax"
605
+ },
606
+ {
607
+ "title" : " Remove All Whitespace" ,
608
+ "description" : " Removes all whitespace from a string." ,
609
+ "code" : [
610
+ " function removeWhitespace(str) {" ,
611
+ " return str.replace(/\\ s+/g, '');" ,
612
+ " }" ,
613
+ " " ,
614
+ " // Example usage:" ,
615
+ " console.log(removeWhitespace('Hello world!')); // Output: 'Helloworld!'"
616
+ ],
617
+ "tags" : [
618
+ " string" ,
619
+ " whitespace"
620
+ ],
621
+ "author" : " axorax"
566
622
}
567
623
]
568
624
},
You can’t perform that action at this time.
0 commit comments