We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d50357 commit 78ab564Copy full SHA for 78ab564
Strings/palindrome.js
@@ -0,0 +1,29 @@
1
+
2
+var isPalindrome = function (text){
3
+ text = text.split('');
4
+ index=0;
5
+ palindrom=true;
6
7
+ pTeks=text.length;
8
9
+ i=0;
10
+ while((i<pTeks/2) && (palindrom===true)){
11
+ if(text[index]==text[pTeks-1]){
12
+ index++;
13
+ pTeks--;
14
+ }else{
15
+ palindrom=false;
16
+ }
17
18
+ i++;
19
20
21
+ return palindrom;
22
+}
23
24
+// test
25
+var cases = "ada apa dengan kakak kakak lari sejak malam ada ada saja";
26
27
+cases.split(" ").map(function(res, i){
28
+ console.log(res+" : isPalindrom? "+isPalindrome(res));
29
+});
0 commit comments