cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="containerHeader">Anagram Checker</div>
<div class="container">
  <div class="pContainer">
  <p>Write a function that checks to determine if two strings are anagrams of each other and appends the answer to the DOM. </p>

<p>Words that are anagrams use exactly the same letters in a different order, such as "rat" and "tar", or "coal" and "cola".</p>

<p>When you click the "Check" button, it should check the strings entered into each input and append the word "true" or "false" to the #answer div.</p>
  </div>
  <div class="inputContainer">
    <input id="word1" placeholder="Enter here"></input>
    <input id="word2" placeholder="Enter here"></input>
    <button id="check">Check</button>
    <div id="answer"></div>
  </div>
</div>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Josefin+Sans:400,600,700');

body{
  font-family: 'Josefin Sans', sans-serif;
  background: #2BBBAD;
  margin-top: 55px;
}

.container{
  background: #fff;
  width: 600px;
  height: 480px;
  text-align: center;
  margin: -25px 0 25px 250px;
  padding: 25px 50px 0 50px;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 0 2px rgba(0,0,0,.12),0 2px 2px rgba(0,0,0,.2)
}

.containerHeader{
  background: #ff4081;
  color: #fff;
  width: 700px;
  height: 130px;
  padding: 35px 0px 0px 0px;
  margin: 35px 0 0 250px;
  border-radius: 5px 5px 0 0;
  font-size: 70px;
  text-align: center;
  z-index: 1000;
}

.pContainer{
  font-size: 20px;
  text-align: justify;
  padding: 0 50px 0 50px;
}

.inputContainer{
  margin: 40px 0 25px 0;
}

#word1{
  height: 25px;
  width: 200px;
  color: #ff4081;
  font-weight: bold;
  border-radius: 5px;
  margin-right: 5px;
  padding-left: 5px;
  display: inline-block;
  border: #ddd 2px solid;
}

#word2{
  height: 25px;
  width: 200px;
  color: #ff4081;
  border-radius: 5px;
  padding-left: 5px;
  font-weight: bold;
  display: inline-block;
  border: #ddd 2px solid;
}

#check{
  height: 50px;
  width: 430px;
  background: #2BBBAD;
  color: #fff;
  border-radius: 5px;
  margin: 30px 0 0px 0;
  font-size: 30px;
  font-weight: bold;
  display: inline-block;
  border: #ddd 2px solid;
}

#check:hover{
  background: #ff4081;
}

#answer{
  margin: 0 0 25px 0;
  font-size: 30px;
  color: #ff4081;
}
@media screen and (max-width: 1100px){
 .containerHeader{
    width: 90%;
    height: 120px;
    margin: 25px;
    padding: 45px 25px 0 25px;
  }
    .container{
    width: 90%;
    height: 500px;
    margin:  -25px 25px 0 25px;
    padding: 10px 25px 0 25px;
  }
  .pContainer{
    width: 80%;
    text-align: center;
    width: 400px;
    margin: 25px 25px 0 25px;
    padding: 10px 25px 0 25px;
    padding: 0;
    font-size: 26px;
    display: inline;
  }
  .inputContainer{
    width: 400px;
    margin: 0;
    display: inline-block;
    
  }
  #word1{
    width:90%;
    margin:0;
    margin-left: -45px;
    vertical-align: middle;
    display: inline-block;
   
  }
  #word2{
    width:90%;
    margin: 5px 0 0 -46px;
    vertical-align: middle;
    display: inline-block;
  }
  #check{
    width:90%;
   margin-left: -50px;
  }
  #answer{
    margin-left: -50px
  }
}

@media screen and (max-width: 730px){
  .containerHeader{
    width: 90%;
    height: 105px;
    margin:  25px 5px 5px 5px;
    padding: 40px 25px 0 25px;
    font-size: 65px;
  }
    .container{
    width: 90%;
    margin:  -5px 5px 5px 5px;
    padding: 10px 25px 0 25px;
      height: 500px;
      
  }
  .pContainer{
    width: 80%;
    text-align: center;
    width: 400px;
    margin: 0;
    padding: 0;
    font-size: 20px;
    display: inline;
  }
  .inputContainer{
    width: 90%;
    margin: 0;
  }

  #word1{
    width:90%;
    margin:0;
    margin-left: -45px;
    vertical-align: middle;
   
  }
  #word2{
    width:90%;
    margin: 5px 0 0 -46px;
    vertical-align: middle;
  }
  #check{
    width:90%;
   margin-left: -50px;
  }
  #answer{
    margin-left: -50px
  }
}
@media screen and (max-width: 550px){
  .containerHeader{
    width: 350px;
    height: 150px;
    margin: 5px;
    padding: 40px 25px 0 25px;
    font-size: 60px;
  }
    .container{
    width: 350px;
    margin:  -5px 5px 5px 5px;
    padding: 10px 25px 0 25px;
    height: 500px;
  }
  .pContainer{
    width: 80%;
    text-align: center;
    width: 400px;
    margin: 0;
    padding: 0;
    font-size: 16px;
    display: inline;
  }
  .inputContainer{
    width: 400px;
    margin: 0;
  }

  #word1{
    width:90%;
    margin:0;
    margin-left: -45px;
    vertical-align: middle;
   
  }
  #word2{
    width:90%;
    margin: 5px 0 0 -46px;
    
    vertical-align: middle;
  }
  #check{
    width:90%;
   margin-left: -50px;
  }
  #answer{
    margin-left: -50px
  }
}
            
          
!
            
              var word1 = [];
var word2 = [];

$('#check').click(function(){
  var word1 = $('#word1').val().toLowerCase().split('').sort().join();
  var word2 = $('#word2').val().toLowerCase().split('').sort().join();
  if(word1 === word2){
    $( "#answer" ).append( "<p>True! This is an anagram.</p>" );
  } else { 
    $( "#answer" ).append( "<p>False! This is an anagram.</p>" );
  }
})

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console