function domainType(domains) {
return domains.map((domain) => {
if (domain.match(/.org$/) !== null)
return "organization"
if (domain.match(/.com$/) !== null)
return "commercial"
if (domain.match(/.net$/) !== null)
return "network"
if (domain.match(/.info$/) !== null)
return "information"
});
}
/**
* Test Suite
*/
describe('domainType()', () => {
it('returns list of domain types', () => {
// arrange
const domains = ["en.wiki.org", "codefights.com", "happy.net", "code.info"];
// act
const result = domainType(domains);
// log
console.log("result: ", result);
// assert
expect(result).toEqual(["organization", "commercial", "network", "information"]);
});
});