FizzBizz Test Challenge

Simple coding challenge for applicants.

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="challenge">
  <h3>FizzBizz Test Challenge</h3>
  <p>Fork this fiddle and complete the following task:</p>
  <blockquote>
    <p>A new fizzBizz feature was released to production, where users discovered it did not meet the requirements below. Your task is to write a test that reproduces the bug</p>
    <p>FizzBizz requirements:</p>
    <ul>
      <li>If <tt>number</tt> is divisible by 3, return 'fizz'.</li>
      <li>If <tt>number</tt> is divisible by 5, return 'bizz'.</li>
      <li>If <tt>number</tt> is divisible by 3 and 5, return 'fizzbizz'.</li>
      <li>Otherwise, return 'not'.</li>
    </ul>
  </blockquote>
  
  <div id="instructions">
    <h4>Requirements</h4>
    <ul>
      <li>Do not edit this fiddle. Use the fork button above.</li>
      <li>Write a test that reproduces the issue.</li>
      <li>Fix the bug. (Optional)</li>
      <li>Feel free to use the browser console. Don't be afraid to ask for help, either.</li>
    </ul>
  </div>
  
  <div id="input">
    <form class="form-inline">
      <button id="main" type="submit" class="btn btn-primary">Test Now!</button>
    </form>
  </div>
  
  <hr />

  <div id="output">
    <h4>Test Result</h4>
    <dl>
      <dt>Pass or Fail?</dt>
      <dd></dd>
    </dl>
  </div>
</div>

CSS

div#challenge {
  padding: 8px;
}

.red {
  color: red;
}

JavaScript

function testFizzBizz() {
  // TODO: Write a test here that returns 'pass' if fizzBizz function below
  // behaves as required, 'fail' if it does not.
  result = 'TBA';
  
  return  result;
}

$('button#main').on('click', testRunner);

function testRunner() {
  var result = testFizzBizz();
  $('div#output dd').text(result);
  return false;	// Do not submit. JSFiddle will give us an error.
}

function fizzBizz(number) {
	// Returns 'fizz', 'bizz', 'fizzbizz', or 'not' according to rules above.
  if ( number % 3 === 0 ) {
    return 'fizz';
  }
  else if ( number % 5 === 0 ) {
    return 'bizz';
  }
  else if ( number % 5 === 0 && number % 3 === 0 ) {
    return 'fizzbizz';
  }
  else {
    return 'not';
  }
}