JSFiddle - React, Tailwind, and code Playground

by yuezk

JavaScript

var country = {
    "1": {
        "Asia": {
            "1": "China",
                "2": "Singapore"
        }
    },
        "2": {
        "Europe": {
            "3": "Germany",
                "4": "France",
                "5": "Russia",
                "6": "Ireland",
                "7": "Holland"
        }
    },
        "3": {
        "Oceania": {
            "8": "Australia"
        }
    },
        "4": {
        "Africa": {
            "9": "Libya"
        }
    },
        "5": {
        "America": {
            "10": "Canada"
        }
    }
};

function getCountry(data) {
    for (var key in data) {
        if (data.hasOwnProperty(key)) {
            if (typeof data[key] == 'object') {
                getCountry(data[key]);
            } else {
                console.log(data[key]);
            }
        }
    }
}

getCountry(country);