function domainType(domains) {
// write code here.
let labels = [];
domains.forEach( element => {
console.log(element.split("."))
let y = (element.split("."));
console.log(y[y.length-1])
if(y[y.length-1] == "org"){
labels.push("organization")
}else if(y[y.length-1] == "com"){
labels.push("commercial")
}else if(y[y.length-1] == "info"){
labels.push("information")
}else if(y[y.length-1] == "net"){
labels.push("network")
}
} );
return labels
}
/**
* 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"]);
});
});