Finding the object in array

Question is to finding the array of object using switch method

let arrayOfObjects = [ { fullName: 'Vishnuprakash', age: 20, country: 'India', city: 'Theni', email: 'vishnu@gmail.com', }, { fullName: 'Robert', age: 23, country: 'London', city: 'Paris', email: 'robert@gmail.com', } ];

Feel free to use dev tools console tab

After finding the name will break the loop

Method

Using switch method and while loop to findout object

let i = 0;

let result;

while (arrayOfObjects.length) {

switch (findingName.toLocaleLowerCase()) {

case arrayOfObjects[i].fullName.toLocaleLowerCase():

result = {

fullName: arrayOfObjects[i].fullName,

age: arrayOfObjects[i].age,

};

i = arrayOfObjects.length;

console.log('Found the person,' + result.fullName);

break;

default:

console.log("Your name is not in this list");

break;

}

i++;

}

console.log(result);