Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const business = [
- {
- id: 1,
- name: "Emcee Enterprises",
- location: [
- {
- id: 1,
- locate: [],
- businesses: []
- },
- {
- id: 2,
- locate: [],
- businesses: []
- },
- ]
- ,
- category: "IT Services",
- phone: "08074037215",
- email: 'u.ezeh@yahoo.com',
- reviews: []
- },
- {
- id: 2,
- name: "Macuval Enterprises",
- location: [
- {
- id: 1,
- locate: [],
- businesses: []
- },
- {
- id: 2,
- locate: [],
- businesses: []
- },
- ]
- ,
- category: "Entertainment Services",
- phone:"08074037215",
- email: 'mac.val@yahoo.com',
- reviews: []
- },
- {
- id: 3,
- name: "Zulu Enterprises",
- location: [
- {
- id: 1,
- locate: [],
- businesses: []
- },
- {
- id: 2,
- locate: [],
- businesses: []
- },
- ]
- ,
- category: "IT Services",
- phone: "08064039014",
- email: 'zulu@yahoo.com',
- reviews: []
- },
- ]
- const newLocation = []
- let key;
- let category = 'IT Services'
- const sample = () => {
- for(key in business){
- console.log(business[key].category)
- // console.log(category)
- if (business[key].category === category){
- newLocation.push(business[key])
- // return newLocation
- }else{
- return 'Category is not Found'
- }
- // return newLocation
- }
- return newLocation
- }
- console.log(sample());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement