Unable to get a compare function to work inside an object

January 28, 2018, at 10:35 AM

I have to make a lottery simulation. 6 numbers between 1 and 49 are to be drawn. A ticket with 6 chosen numbers from that ranged is to be compared with the lottery numbers. The data to be returned includes the drawn numbers, the numbers from the ticket and the count of matching numbers between the lottery draw and the ticket.

Note that I was instructed to create two classes, the first of which to generate random numbers. The second should have two methods. The first should draw the 6 numbers in the lottery. The second should take the 6 ticket numbers and compare the two pairs of numbers.

I have successfully compiled a function which conducts the draw. The numbers from the ticket are just presented in an array. I have a function which compares the two arrays, but it does not work in the code. I assume the reason is in the way the function is passed the numbers from the draw. If it is passed two random arrays, it works fine.

This is my attempt at the solution so far:

function Lottery() {
function Generator() {
var genNumber = Math.floor((Math.random() * 49) + 1);
return genNumber;
function Totalizer() {
this.drawNumbers = function DrawNumbers() {
var arr = []
while(arr.length < 6) {
    var randomNum = Generator();
    if (arr.indexOf(randomNum) > -1) {
    arr[arr.length] = randomNum;
return arr.sort(function(a, b) {return a - b});
this.ticketNumbers = [16, 27, 7, 1, 17, 3].sort(function(a, b) {return a - b});
this.compNumbers = function CompNumbers(winNumbers, ticketNumbers) {
    var winNumbers = this.drawNumbers();
    var ticketNumbers = this.ticketNumbers;
    var same = [];
    for (var i = 0; i < winNumbers.length; i++) {
    for (var j = 0; j < ticketNumbers.length; j++) {
    if (winNumbers[i] === ticketNumbers[j]) {
    return same.length;
var checkRes = new Totalizer();
Rent Charter Buses Company
JSZip files can&#39;t be unzipped

JSZip files can't be unzipped

I want to download multiple files in a zip fileWhen the zip file downloads and I try opening it, I get the following error on macos 'unable to expand test into downloads (Error 1 - Operation not permitted)'

Bind iron-page and and

Bind iron-page and and

I just began to learn the Polymer and at the moment to bind the paper-tabs and iron-pages together, so if I click the tab the content will be loaded dynamicallyAfter reading the documentation here is what I have at the moment

Stop fetching chats in javascript chat tool works in chrome

Stop fetching chats in javascript chat tool works in chrome

I work on a chat tool which works on Javascript in chromeHow do I stop it fetching chats in chrome

JavaScript for loop diffi

JavaScript for loop diffi

Here is the code I wrote: