function domainType(domains) {
// write code here.
let domResult = [];
for (let i = 0; i < domains.length; i++) {
let address = domains[i].split(".");
switch(address[address.length-1]) {
case "org": domResult.push("organization");
break;
case "com": domResult.push("commercial");
break;
case "net": domResult.push("network");
break;
case "info": domResult.push("information");
break;
default: domResult.push("other");
}
}
return domResult;
}
/**
* 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"]);
});
});