JSFiddle - React, Tailwind, and code Playground

[ASSIGNMENT] Close Frontend Technical Call 2 Domain Parts

by philfreo

JavaScript

/**
 * Write a function that splits a domain name into its subdomains, 
 * e.g. parts('www.google.com') should return ['com', 'google.com', 'www.google.com'].
 * It should work with any amount of parts, e.g. parts('www.calendar.google.com')
 * should return
 * ['com', 'google.com', 'calendar.google.com', 'www.calendar.google.com']
 *
 * What is your code's time complexity? (using Big O notation O(…))
 
 */

function parts(domain) {

}

console.log(parts('www.google.com'));
console.log(parts('www.calendar.google.com'));