Explore BrainMass

A javascript function showing how to generate random numbers

Please see the attached file.


Solution Preview

This requires creating a Javascript function to read in the user provided values and then randomly pick four numbers until they match the user's numbers. The number of attempts is displayed. The following Javascript code does this:

function Lottery()
var pickOne, pickTwo, pickThree, pickFour, attempts;
var numOne, numTwo, numThre, numFour;

attempts = ...

Solution Summary

This solution demonstrates how to write a javascript function that picks random numbers. Also included with the solution is an HTML file that uses the javascript function.