JSFiddle - React, Tailwind, and code Playground

JavaScript

var myArray = [{nemo : {type: "fish", scales: "yes"}}, 
{bubbles : {type: "fish", scales: "yes"}}, 
{jimmy : {type: "turtle", scales: "no"}}];


function findType (array, animalType) {
     var newArray = [];
     for (i = 0; i < array.length; i ++){
    for(var name in array[i]){
    console.log(name);
    if(array[i][name].type == animalType){
      newArray.push(array[i]);
    }
      }
    }
     return newArray;
};

console.log(findType(myArray, "fish"));