Object type variable calculatd fields?

Hi,
Is it possible to use JS object type variable into the calculated fields, as in the example below?
When I use this code I get this error message: Unexpected end of input

(function () {

let options = [

    { "field": "fieldname274", "value": 12, "name": "John" },

    { "field": "fieldname275", "value": 25, "name": "Peter" },

    { "field": "fieldname276", "value": 20, "name": "Marc" },

    { "field": "fieldname277", "value": 10, "name": "Marie" },

    { "field": "fieldname278", "value": 40, "name": "George" },

    { "field": "fieldname279", "value": 50, "name": "Stanley" },

];

let maxValue = -1,

    maxOccurrence = 3,

    results = [],

    message = "";

for (let i = 0; i < options.length; i++) {

    if (maxValue < options[i].value) {

        maxValue = options[i].value;

        //reset results

        results = [];

        //add element to results;

        results.push(options[i].name);

    }

    else if (maxValue == options[i].value) {

        //add element to results;

        results.push(options[i].name);

    }

}

console.log(<code>max value value is ${maxValue}</code>);

if (results.length > maxOccurrence) {

    let message = results.join(", ");

    console.log(<code>You are scoring ${maxValue} for ${message}?</code>);
    return maxValue;

}

else {

    let message = results.join(", ");

    console.log(<code>You've got the score of ${maxValue} for ${message}</code>);
    return maxValue;

}

})()
  • This topic was modified 4 hours, 19 minutes ago by Radovan.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer