Skip to content

Instantly share code, notes, and snippets.

@u-r-w
Last active October 20, 2018 23:38
Show Gist options
  • Save u-r-w/423ed246a69174e2fe29de612f491590 to your computer and use it in GitHub Desktop.
Save u-r-w/423ed246a69174e2fe29de612f491590 to your computer and use it in GitHub Desktop.
#!/home/umar/.nvm/versions/node/v8.11.3/bin/node
let fs = require("fs");
let text = fs.readFileSync("text.txt", "utf-8");
text.split("\n").forEach(function(line) {
let reverse = line.split("").reverse().join("")
if (line.toLowerCase() === reverse) {
console.log("Detected palindrome at:", line);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment