scrimba
Note at 0:04
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:04
AboutCommentsNotes
Note at 0:04
Expand for more info
main.js
run
preview
console
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"]);
});
});
Console
[
"en"
,
"wiki"
,
"org"
]
,
"org"
,
[
"codefights"
,
"com"
]
,
"com"
,
[
"happy"
,
"net"
]
,
"net"
,
[
"code"
,
"info"
]
,
"info"
,
"result: "
,
[
"organization"
,
"commercial"
,
"network"
,
"information"
]
,
/index.html
LIVE