Created
March 14, 2024 03:09
-
-
Save Risyandi/479be9dcfdad051f6dba9ae1282fadd5 to your computer and use it in GitHub Desktop.
palindrome code test for eigerindo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// checking if the text is palindrome | |
function palindrome(string) { | |
let result = true; | |
let lengthString = string.length; | |
let indexJ = lengthString - 1; | |
for (let index = 0; index < lengthString / 2; index++) { | |
if (string[index] != string[indexJ]) { | |
result = false; | |
} | |
indexJ--; | |
} | |
// result log | |
console.log(result, 'result'); | |
return result; | |
} | |
let stringText = 'satas'; | |
palindrome(stringText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using programming language golang