function domainType(domains) {
// write code here.
d_types = []
domains.forEach(domain => {
list = domain.split(".")
d_type = list[list.length-1]
if ( d_type == 'org'){
d_types.push("organization")
}else if(d_type == 'com'){
d_types.push("commercial")
}else if(d_type == 'net'){
d_types.push("network")
}else if(d_type == 'info'){
d_types.push("information")
}
})
return d_types
}
/**
* 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"]);
});
});