I have a beginner question. I am using an ajax call to get elements of a sharepoint list choice(checkboxes) column called "Orbit" to create a google pie chart:
data.d.results.forEach(function(row) {
// each row
row.Orbit.results.forEach(function(choiceOrbit) {
// each choice of Orbit of single row
if (countOrbit.hasOwnProperty(choiceOrbit)) {
countOrbit[choiceOrbit] += 1;
} else {
countOrbit[choiceOrbit] = 1;
}
});
But if the item EDIT: (if the row is empty) i get an error:
Uncaught TypeError: Cannot read property 'results' of null
at Statistics.aspx:658
at Array.forEach (<anonymous>)
at Object.success (Statistics.aspx:632)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
How can i add an if(), so that an empty item will be neglected in the counting? Something like:
if(row.Wavebands.results.forEach!=null)
doesnt work