JSFiddle - React, Tailwind, and code Playground

by Ray Toal

HTML

<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css">
<div id="qunit"></div>
<div id="qunit-fixture"></div>

JavaScript

/*
 * A collection of functions to satisfy a homework assignment on basic JavaScript.
 */

/*
 * Returns an array with the minimum number of U.S. quarters, dimes, nickels, and pennies,
 * respectively, that make the given amount.  Precondition: the amount is a nonnegative
 * integer in the range of JavaScript contiguous integers.
 */
var change = function (amount) {
  var QUARTER_VALUE = 25, DIME_VALUE = 10, NICKEL_VALUE = 5;

  var quarters = Math.floor(amount / QUARTER_VALUE);
  amount %= QUARTER_VALUE;
  var dimes = Math.floor(amount / DIME_VALUE);
  amount %= DIME_VALUE;
  var nickels = Math.floor(amount / NICKEL_VALUE);
  var pennies = amount % NICKEL_VALUE;
  return [quarters, dimes, nickels, pennies];
};

/*
 * Returns the string just like s except with ASCII vowels removed.
 */
var stripVowels = function (s) {
  return s.replace(/[aeiou]/gi, "");
};

/*
 * Returns a random permutation of the given string.  This is a direct implementation
 * of the Fisher-Yates shuffle, which is awesome.  Don't use the random technique! See
 * http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/
 */
var scramble = function (s) {
  var a = s.split("");
  for (var i = a.length; i > 0; i--) {
    var j = Math.floor(i * Math.random());
    var save = a[i];
    a[i] = a[j];
    a[j] = save;
  }
  return a.join("");
};

/*
 * Produces successive powers of two, up to the given limit, passing each to a callback.
 */
var powersOfTwo = function (limit, callback) {
  for (var x = 1; x <= limit; x += x) {
    callback(x);
  }
};

/*
 * Produces successive powers of a given base, up to the given limit, passing each to a
 * callback. Precondition: base is strictly greater than 1.
 */
var powers = function (base, limit, callback) {
  for (var x = 1; x <= limit; x *= base) {
   callback(x);
  }
};

/*
 * Returns the interleaving of two arrays.  The lengths of the arrays do not need to be
 * the same.
 */
var interleave = function (a, b) {
  var alength =...