Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
How to calculate sum of multiple responses in javascript?

The code below outputs numeric data

          var meshInstances = entity.model.meshInstances;
          var mat;
          for(var i = 0; i < meshInstances.length; i++) {
     //  mat = meshInstances[i].mesh.vertexBuffer.numVertices;
          mat = parseFloat(meshInstances[i].mesh.indexBuffer[0].numIndices / 3);
console.log(mat);

enter image description here

How to output this data as a sum of all responses? 1 Line with sum

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Thanks Anas Abdullah Al Changed it a little and it worked, was getting 'NaN' previously

var meshInstances = entity.model.meshInstances;
var mat;
var total = 0;
for (var i = 0; i < meshInstances.length; i++) {
    //  mat = meshInstances[i].mesh.vertexBuffer.numVertices;
    mat = parseFloat(meshInstances[i].mesh.indexBuffer[0].numIndices / 3);
    total += mat;
}
console.log(total);
about 4 years ago · Juan Pablo Isaza Report

0

You can do something like this...

var meshInstances = entity.model.meshInstances;
var mat, total;
for (var i = 0; i < meshInstances.length; i++) {
    //  mat = meshInstances[i].mesh.vertexBuffer.numVertices;
    mat = parseFloat(meshInstances[i].mesh.indexBuffer[0].numIndices / 3);
    total += mat;
}
console.log(total);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!