scrimba
Note at 0:00
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:00
by
AboutCommentsNotes
Note at 0:00
by
Expand for more info
main.js
run
preview
console
const mapped = {
org: "organization",
com: "commercial",
net: "network",
info: "information"
};

const domainType = (domains) => {
let domStore = [];
domains.map((domain) => {
domStore[domStore.length] = mapped[domain.split(".").splice(-1,1)];

});
return domStore;
};



//option 2
// const domainType=(domains)=> {
// let main=domains.length

// return domains.map((item)=>{
// item.includes(".org")
// ?main="organization"
// :item.includes(".com")
// ?main="commercial"
// :item.includes(".net")
// ?main="network"
// :item.includes("info")
// ?main="information"
// :item

// return main
// })
// }


/**
* Test Suite
*/
describe('domainType()', () => {
it('returns list of domain types', () => {
// arrange
const domains = ["en.wiki.org", "codefights.com", "happy.net", "code.info", "test.info"];

// act
const result = domainType(domains);

// log
console.log("result: ", result);

// assert
expect(result).toEqual(["organization", "commercial", "network", "information","information"]);
});



});
Console
"result: "
,
[
"organization"
,
"commercial"
,
"network"
,
"information"
,
"information"
]
,
/index.html
LIVE