UNPKG

learnyounode

Version:

Learn You The Node.js For Much Win! An intro to Node.js via a set of self-guided workshops.

28 lines (19 loc) 601 B
'use strict' const exercise = require('workshopper-exercise/basic') // generate a random positive integer <= 100 function rndint () { return Math.ceil(Math.random() * 100) } exercise.addSetup(function (mode, callback) { // mode == 'run' || 'verify' // create a random batch of cmdline args const args = [rndint(), rndint()] while (Math.random() > 0.3) { args.push(rndint()) } // supply the args to the 'execute' processor for both // solution and submission spawn() this.submissionArgs = this.solutionArgs = args process.nextTick(callback) }) module.exports = exercise