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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <script src='https://scottdalessandro.github.io/jasmine-total/js/jasmine-suite.min.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<div class='container-fluid'>
  <!-- Nav tabs -->
  <ul class="nav nav-tabs" id="myTab" role="tablist">
    <li class="nav-item">
      <a class="nav-link active" data-toggle="tab" href="#problem" role="tab">Challenge & Examples</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" data-toggle="tab" href="#testspecs" role="tab">Test Specs</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" data-toggle="tab" href="#run-specs" role="tab">Run Specs</a>
    </li>
  </ul>

  <!-- Tab panes -->
  <div class="tab-content">
    <div class="tab-pane active" id="problem" role="tabpanel">
      <div class='jumbotron' id="probjumbo">
      </div>
    </div>
    <div class="tab-pane" id="testspecs" role="tabpanel">
      
      <h4>SPECS </h4>
      <pre> 
        <code id="codeblock" class="language-javascript"> 
        </code> 
      </pre>
     
    </div>
    <div class="tab-pane" id="run-specs" role="tabpanel">

    </div>
  </div>

</div>


<script id="test-data">
/*
STARTPROBLEM

## Nickname Generator

Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as that name's nickname!  If the 3rd letter is a vowel, return the first 4 letters. 


**Examples**:


- **INPUT**: `nicknameGenerator('Daniel')`
- **OUTPUT**: `'Dan'`



- **INPUT**: `nicknameGenerator('Beowulf')`
- **OUTPUT**: `'Beow'`


ENDPROBLEM
*/       
 
/// STARTSPECS
describe('nicknameGenerator', function() {
  it('is a function', function() {
    expect(typeof nicknameGenerator).toBe('function');
  });

  it('returns a string', function() {
    expect(typeof nicknameGenerator('Casey')).toBe('string');
  });

  it('returns the argument if the length is 3 or less', function() {
    expect(nicknameGenerator('Joe')).toEqual('Joe');
  });

  it('returns first three letters of the argument string', function() {
    expect(nicknameGenerator('Daniel')).toBe('Dan');
  });

  it('returns the first 4 letters if the third letter is a vowel', function() {
    expect(nicknameGenerator('Beowulf')).toBe('Beow');
  });
});
/// ENDSPECS
</script>

<script>


   
    var testData = document.getElementById("test-data").innerHTML;
    var probData = [], specData = [];
    var insideProb = false, insideSpec = false;

    testData.split(/\n/).forEach(line => {
      if(line.indexOf("STARTPROBLEM") >= 0) {
        insideProb = true;
      } else if(line.indexOf("ENDPROBLEM") >= 0) {
        insideProb = false;
      } else if(line.indexOf("STARTSPECS") >= 0) {
        insideSpec = true;
      } else if(line.indexOf("ENDSPECS") >= 0) {
        insideSpec = false;
      }
      if(insideProb) { probData.push(line) };
      if(insideSpec) { specData.push(line) };
    });

    probHTML = marked(probData.slice(1).join("\n"));
    document.getElementById("probjumbo").innerHTML = probHTML;  
    specHTML = "\n" + specData.slice(1).join("\n");
    document.getElementById("codeblock").innerHTML = specHTML;  

    $(document).ready(function() { 
      document.getElementById('run-specs').appendChild(document.getElementsByClassName('jasmine_html-reporter')[0]);
    });


</script>
            
          
!
            
              /* Write Code Here */










//EXAMPLE TESTS:

console.log(nicknameGenerator('Daniel'));
//OUTPUT: 'Dan'

console.log(nicknameGenerator('Beowulf'));
//OUTPUT: 'Beow'
            
          
!
999px
Loading ..................

Console