Skip to content

Instantly share code, notes, and snippets.

@jochri3
Created September 3, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jochri3/7eb5d78ecd21aef65d82e52df38bdb22 to your computer and use it in GitHub Desktop.
Save jochri3/7eb5d78ecd21aef65d82e52df38bdb22 to your computer and use it in GitHub Desktop.
null created by ChrisLis - https://repl.it/HaKw/34
// Write a function that takes a string and returns true if it is a
// palindrome. A palindrome is a string that is the same whether written
// backward or forward. Assume that there are no spaces; only lowercase
// letters will be given.
//
// Difficulty: easy.
function is_palindrome(string) {
var contraire=string.split("").reverse().join("");
if(contraire==string)
{
return true
}
else
{
return false
}
}
// These are tests to check that your code is working. After writing
// your solution, they should all print true.
console.log("\nTests for //palindrome?")
console.log("===============================================")
console.log('is_palindrome("abc") == false: ' + (is_palindrome('abc') === false));
console.log('is_palindrome("abcba") == true: ' + (is_palindrome('abcba') === true));
console.log('is_palindrome("z") == true: ' + (is_palindrome('z') === true));
console.log("===============================================")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment