scrimba
Note at 0:40
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:40
AboutCommentsNotes
Note at 0:40
Expand for more info
main.js
run
preview
console
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"]);
});
});
Console
"result: "
,
[
"organization"
,
"commercial"
,
"network"
,
"information"
]
,
/index.html
LIVE