#! /usr/bin/perlusewarnings;usestrict;sub format_words{my@words=greplength,@_;my$last=pop@words;returnjoin(', ',@words).(@words?" and $last":"")}useTest::Moretests=>3;isformat_words('ninja','samurai','ronin'),'ninja, samurai and ronin';isformat_words('ninja','','ronin'),'ninja and ronin';isformat_words(),"";
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Perl solution, tests included: