Created
May 23, 2016 19:05
-
-
Save agsdot/bdd770791d5cef3fd87ebad89e871a53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var options = { | |
method: 'GET', | |
json: {}, | |
uri: 'https://api.clever.com/v1.1/districts/4fd43cc56d11340000000005/sections', | |
headers: { | |
Authorization: 'Bearer DEMO_TOKEN' | |
} | |
}; | |
request(options, function(err, response, body) { | |
var numberOfSections, studentTotal, avgStudentsPerSection; | |
numberOfSections = body.data.length; | |
studentTotal = body.data.reduce(function(prevValue, currValue) { | |
var studentCountSection = currValue.data.students.length; | |
var studentCountTotal = studentCountSection + prevValue; | |
return studentCountTotal; | |
}, 0) | |
avgStudentsPerSection = studentTotal / numberOfSections; | |
console.log("number of sections"); | |
console.log(numberOfSections); | |
console.log("total number of students in all the sections"); | |
console.log(studentTotal); | |
console.log("average number of students per section"); | |
console.log(avgStudentsPerSection) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment