Domain Type From Array Of Urls

  function domainType(domains) {     //  write code here.     let result = []     for(let i=0; i<domains.length; i++){         domain_typ...

 


function domainType(domains) {

    //  write code here.

    let result = []

    for(let i=0; i<domains.length; i++){

        domain_type = (domains[i].split('.')).slice(-1)[0]

        if (domain_type == "org"){

            result.push("organization")

        }

        else if (domain_type == "com"){

            result.push("commercial")

        }

        else if (domain_type == "net"){

            result.push("network")

        }

        else if (domain_type == "info"){

            result.push("information")

        }

        else{

            console.log("Invalid domain name...")

        }

    }

    return result

}


/**

* 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"]);

    });

});

COMMENTS

Name

Accident Alert,1,AI,2,Array,1,Aurdino,1,C,2,Computer Graphics,9,Data Science,3,Dataset,1,Decoratot,1,Django,1,ESP32,1,Fixed point/iteration method,1,Greater or smaller,1,html,1,Image Processing,1,JAVA,1,Javascript,22,Machine Learning,1,Matlab,3,Numerical Method,13,OOP,1,Other,3,PHP,1,Point operation,1,Python,11,Raspberry pi,1,Recommendation System,1,Regression,1,Reservation System,1,Robotics,1,Simulation,2,sine wave,1,String Handling Function,1,Web scrap,1,Webpage,1,
ltr
item
COMPUTER PROGRAMMING: Domain Type From Array Of Urls
Domain Type From Array Of Urls
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8YcvRT5UdGTVwb1Fis0-QgCdr1JFIdYXmI2IB6LTafJFSZZGh0ssw79d6T-WavmWUkMliaa8j4BDv-xu9v8yvA2Nn5McK7hJ9B09PyZa6n-OtWr4R8moLiPpIiNYzvVuvefdNhQNm5rMi/w640-h310/Screenshot+from+2020-12-20+16-00-13.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8YcvRT5UdGTVwb1Fis0-QgCdr1JFIdYXmI2IB6LTafJFSZZGh0ssw79d6T-WavmWUkMliaa8j4BDv-xu9v8yvA2Nn5McK7hJ9B09PyZa6n-OtWr4R8moLiPpIiNYzvVuvefdNhQNm5rMi/s72-w640-c-h310/Screenshot+from+2020-12-20+16-00-13.png
COMPUTER PROGRAMMING
https://computerprogram4ru.blogspot.com/2020/12/domain-type-from-array-of-urls.html
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/2020/12/domain-type-from-array-of-urls.html
true
8672391763020279633
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy