Im super confused. I am trying to use pure JS to test if there are any elements with the class name .example on a page with a few instances of .example but I cant get consistent results...
<script>
var example = document.getElementsByClassName('example');
console.log( example );
// gives [],
0:div.example
1:div.example
2:div.example
length:3
console.log(example.length);
// gives 0
console.log(example[0])
// gives undefined
</script>
Is something weird going on with my computer or am I missing something? How should I access the length property?