Atom feed

Recently added: 128 Longest Consecutive Sequence, 347 Top K Frequent Elements, 045 Jump Game 2, 228 Summary Ranges, 219 Contains Duplicate 2

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:23:16+05:30 · Edit