Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <article>
  <h2>JavaScript Arrays</h2>
  <section>
    
    <aside id="left">
      <p>Player</p>
      <ul id="list">

      </ul>
    </aside>
    
    <aside id="mid">
      <p>First Name</p>
      <ul id="firstName">

      </ul>
    </aside>
    
    <aside id="right">
      <p>Last Name</p>
      <ul id="lastName">

      </ul>
    </aside>
    
  </section>
</article>
              
            
!

CSS

              
                *{
  text-align:center;
}
section{
  border:solid 2px black;
  border-radius: 10px;
  width: 75%;
  max-width:400px;
  margin:auto;
  padding:5px;
  background-color: #2d3e50;
}
article {
  width: 100%;
  text-align: center;
}
p {
  border:solid 2px black;
  border-radius: 3px;
  background-color:#00bda5;
  margin: 0px;
  padding:1px;
  color: #2d3e50;
}
#left {
  display: inline-block;
  width: 20%;
}
#mid{
  display:inline-block;
  width: 37.5%;
}
#right {
  display: inline-block;
  width: 37.5%;
}
ul {
  list-style: none;
  display:block;
  padding: 0px;
  margin: 0px;
}
li {
  border: solid 2px black;
  border-radius: 5px;
  text-align:left;
  color: white;
  margin-top: 5px;
  padding: 5px;
  background-color:#ff5c35;
  text-align:center;
}
              
            
!

JS

              
                //Create an empty array to hold mofidied data
let playerInfo = [];

function fullName(id, arr) {    
  
  //Create and append LI for Player Information column, then set #id attribute
    let playerFrstNm = document.createElement("LI");
    document.getElementById("firstName").appendChild(playerFrstNm);
    playerFrstNm.setAttribute("id", `playerFstNm${id}`);
    
    //Create and append LI for Player Information column, then set #id attribute
    let playerLstNm = document.createElement("LI");
    document.getElementById("lastName").appendChild(playerLstNm);
    playerLstNm.setAttribute("id", `playerLstNm${id}`);
    
    //Create and append LI for Player column, then set #id attribute
    let playerNumber = document.createElement("LI");
    document.getElementById("list").appendChild(playerNumber);
    playerNumber.setAttribute("id", `playerNum${id+1}`);
  
    let playerNum = document.createTextNode(`${id+1}.)`);
    playerNumber.appendChild(playerNum);
  
  //Return fullName item
  return playerInfo[id];
}

function playerHTML(){
  
}
//Provided array to iterate over, modify and add to new array
firstNames = ['Dennis', 'Deandra', 'Frank'];

//Use forEach method to iterate over and and create new array with modified data
firstNames.forEach(
  function(firstName, id, arr) {
    //Modify the name and add to the fullName array
    playerFull= `${firstName} Reynolds`;
    playerInfo.push(playerFull.split(" "));
    //Display the current item in the first name array
    let playerName = fullName(id, arr);
    
    //Create text node for player information item and comma
    document.getElementById(`playerFstNm${id}`).appendChild(document.createTextNode(`${playerName[0]}`));
    document.getElementById(`playerLstNm${id}`).appendChild(document.createTextNode(`${playerName[1]}`));
  },
playerInfo);

              
            
!
999px

Console