expected. Insert a semicolon at the end. When the end that it says, is a } Could someone help us fix this?

We are working on putting arrays on our hardcoded android quiz game. We searched for example codes such as the code in this one : JavaScript Trivia Game (or in the attachment)

But when we tried to run it on Unity, errors will show. For example,

Assets/trivia/trivia.js(43,4): UCE0001: ‘;’ expected. Insert a semicolon at the end.

When the end that it says, is a }

Could someone help us fix this?

(A PART OF THE CODE)

  var quizzes = [];
  // sets the <select> list with categories, that will be added in #tcateg
  // Receives an object with "category":"file_name" elements, and the type of the files ('xml', or 'json')
  this.setCateg = function(objf, type) 
  {
    objfiles = objf;
    var tcateg = '';  var propf = '';
    var i = 0; // to can call the method that sets the quizzes, with the first file_name
    for(var prop in objfiles) 
    {
      if(i === 0) propf = prop;
      i = 1;
      tcateg += '<option value='+ prop +'>'+ prop +'</option>';
    }
    // calls thee method to set the trivia quizzes of first category
    if(type == 'xml') obth.setQuizXML(propf);
    else obth.setQuizJSON(propf);
    // sets onchange event for <select> with method to call according to type, adds the select list
    var onchg = type == 'xml' ? 'onchange="obTrivia.setQuizXML(this.value)"' : 'onchange="obTrivia.setQuizJSON(this.value)"';
    if(document.getElementById('tcateg')) document.getElementById('tcateg').innerHTML = 'Trivia Category: <select '+ onchg +'>'+ tcateg +'</select>';
  }

It looks like you are trying to use javascript from a web page inside Unity. Unfortunately that doesn’t work. The ‘javascript’ which unity uses is actually UnityScript.

The problem lies in line 21, the {} begins in line 4 which defines a delegate. This means there has to be a semicolon, unlike regular if clauses for example.