function BackgroundGenerator() {
  this.hue = Math.floor(Math.random()*360);
  this.pattern = this.PATTERNS[Math.floor(Math.random()*this.PATTERNS.length)];
}

BackgroundGenerator.prototype = {
  PATTERNS: ['checkerboard', 'dots', 'striped'],

  toClassName: function() {
    return `${this.pattern} bg-${this.hue}`;
  },
};

module.exports = BackgroundGenerator;

var PATTERNS = ['checkerboard', 'dots', 'striped'];

class BackgroundGenerator {
  constructor() {
    this.hue = Math.floor(Math.random()*360);
    this.pattern = PATTERNS[Math.floor(Math.random()*PATTERNS.length)];
  }

  toClassName() {
    return `${this.pattern} bg-${this.hue}`;
  }
}

module.exports = BackgroundGenerator;

Use ES6 class syntax for BackgroundGenerator
Use ES6 class syntax for BackgroundGenerator

Why not. Move PATTERNS to private var rather than prototype property
since it shouldn't be modified or accessed.
