this Javascript code gives output as [object, Object] , instead of [f, dog].??
<html>
<body>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
var animals = [{name:'f', species :'dog'},{name:'f1', species :'dog1'}];
function isSog(animal) {
if(animal.species==='dog') return animal;
}
function myFunction() {
document.getElementById("demo").innerHTML = animals.filter(isSog);
}
</script>
</body>
</html>