Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

043 Domain Type

 * Ashish Patel
 * e:
 * w:

GoDaddy makes a lot of different top-level domains available to its customers. A top-level domain is one that goes directly after the last dot ('.') in the domain name, for example .com in To help the users choose from available domains, GoDaddy is introducing a new feature that shows the type of the chosen top-level domain. You have to implement this feature. To begin with, you want to write a function that labels the domains as "commercial", "organization", "network" or "information" for .com, .org, .net or .info respectively. For the given list of domains return the list of their labels.


For domains = ["", "", "", ""], the output should be domainType(domains) = ["organization", "commercial", "network", "information"].

function domainType(domains) {
  const domainLookup = {
    'org': 'organization',
    'com': 'commercial',
    'net': 'network',
    'info': 'information'
  return => domainLookup[domain.split('.').pop()])

test('domain Type', () => {
  expect(domainType(['', '', '', '' ])).toEqual(['organization', 'commercial', 'network', 'information'])

Created 2019-12-14T23:11:16+05:18 · Edit