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.

            
              <form name="names">
  <input type="text" id="box1" name="firstlastname" placeholder="Luke Skywalker"><br>
  <input type="text" id="box3" name="domain" placeholder="disney.com"><br>
  <input type="text" id="box2" name="sep" placeholder="Optional: custom separator"><br>
  <input type="submit" id="button-make" value="Make Variations" onClick="permutate(this.form);return false;">
</form>

<input type="submit" id="button-reset" value="Reset" onClick="reset('results');return false;">

<div id="results"></div>


            
          
!
            
              #form{
  margin-top: 20px;
}

input[type]{
  font-size: 25px;
  font-family: arial;
}

#box1, #box2, #box3{
  width: 317px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid rgb(200,200,200);
  border-top-color: rgb(100,100,100);
  border-radius: 5px;
  color: #5A5A5A;
}

#button-reset{
  position:relative;
  display:inline-block;
}

#button-make, #button-reset{
  float:left;
}

#button-reset{
  margin: 0 0 0 10px;
}

#results{
  position: relative;
  display: block;
  overflow: auto;
  margin-top: 45px;
  padding: 15px;
  border: 1px solid rgb(200,200,200);
  /*border-bottom: 1px solid rgb(200,200,200);*/
  background: rgb(245,245,245);
  color: rgb(50,50,50);
  font-size: 20px;
  line-height: 36px;
  font-family: arial;
}
            
          
!
            
              function permutate(form) {

  var firstlastname = form.firstlastname.value.toLowerCase().trim();
  var namesplit = firstlastname.split(" ");
  var firstname = namesplit[0];
  var lastname = namesplit[1];
  var domain = form.domain.value.toLowerCase().trim();
  var sep = form.sep.value + ' ';
  //var sep = ", ";
  
  if (firstname==null || firstname==""){
    document.getElementById("results").innerHTML= "Please provide a first name e.g. Luke";
    return false;    
  } else if (lastname==null || lastname==""){
    document.getElementById("results").innerHTML= "Please provide a last name e.g. Skywalker";
    return false;    
  } else if (domain==null || domain==""){
    document.getElementById("results").innerHTML= "Please provide a domain e.g. yahoo.com";
    return false;
  } else {}
  
  //If no optional separator, defult to comma
  if (sep==null || sep==" "){
    sep = ", ";
  }
  
  //bob@domain.com
  var p1 = firstname + "@" + domain + sep;
  
  //bobsmith@domain.com
  var p2 = firstname + lastname + "@" + domain + sep;
  
  //bob.smith@domain.com
  var p3 = firstname + "." + lastname + "@" + domain + sep;
  
  //smith@domain.com
  var p4 = lastname + "@" + domain + sep;
  
  //bsmith@domain.com
  var p5 = firstname.charAt(0) + lastname + "@" + domain + sep;

  //b.smith@domain.com
  var p6 = firstname.charAt(0) + "." + lastname + "@" + domain + sep;
  
  //bobs@domain.com
  var p7 = firstname + lastname.charAt(0) + "@" + domain + sep;
  
  //bob.s@domain.com
  var p8 = firstname + "." + lastname.charAt(0) + "@" + domain + sep;
  
  //bs@domain.com
  var p9 = firstname.charAt(0) + lastname.charAt(0) + "@" + domain;
  
  var addresses= p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
  
	document.getElementById("results").innerHTML= addresses;
}

function reset(results) {
  document.getElementById("results").innerHTML= "";
  document.getElementById("box1").value = "";
  document.getElementById("box3").value = "";
  document.getElementById("box2").value = "";
}
            
          
!
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