Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <div class="container">
        <h1>Palindrome Checker - FreeCodeCamp Project</h1>

        <p>You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the
        same case (lower or upper case) in order to check for palindromes.</p>
        <h2>Try it out!</h2>
        <input type="text" name="palindromeTest" id="stringInput" placeholder="Type string to test here." />
        <input type="button" value="Launch test" onclick="palindrome()" id="launchButton" />
        <p id="result">The result, either "true" or "false", will be displayed here.</p>
        <a href="">GitHub Repo</a>

      <script src="palindrome.js"></script>
      <script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>





                //get launch button
launchButton = document.getElementById("launchButton");

const palindrome = () =>{
    // var string = document.getElementById("string").value;
    var string = document.getElementById('stringInput').value;
    //initialize variable for reversed version of string entered
    var reversedString = "string";

    //boolean that will hold and display palidrome() result on page
    var result = true;
    //element that will display result
    displayResult = document.getElementById("result");

    //strip  non-alphanumeric characters
    string = string.replace(/[^A-Za-z0-9]/g, '');
    string = string.toLowerCase();

    //function to reverse string
    function reverse(s) {
        return s.split('').reverse().join('');
    reversedString = reverse(string);

    //display true/false in #result, returned value from palindrome call
    if (string == reversedString) {//check whether original and reverted are the same
        result = true
        displayResult.innerHTML = "true";
    } else {
        displayResult.innerHTML = "false";

//listen for click event on launch button
launchButton.addEventListener("click", palindrome);