Skip to content

Instantly share code, notes, and snippets.

@sanket143
Created May 28, 2017 11:26
Show Gist options
  • Save sanket143/d10dd32cb0f957d5962a6e9e8fd6ab13 to your computer and use it in GitHub Desktop.
Save sanket143/d10dd32cb0f957d5962a6e9e8fd6ab13 to your computer and use it in GitHub Desktop.
To calculate percentage
var marks = [];
var total = 0 ;
function Calculate(marks) {
for(i=0; i < marks.length ; i++) {
total = total + marks[i];
var percentage = total/marks.length ;
} return percentage;
}
Calculate([97,93,94]) ; // here comes your marks
// no matter the number of subjects, its Auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment