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; } })()
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Object type variable calculatd fields?’ is closed to new replies.