{"id":132,"date":"2021-08-06T05:39:07","date_gmt":"2021-08-06T05:39:07","guid":{"rendered":"https:\/\/clvrclvr.com\/content\/?p=132"},"modified":"2021-08-06T06:04:23","modified_gmt":"2021-08-06T06:04:23","slug":"an-es6y-solution-for-codewars-trolls","status":"publish","type":"post","link":"https:\/\/clvrclvr.com\/content\/?p=132","title":{"rendered":"An ES6y Solution for Codewars&#8217; Trolls"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Description:<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.codewars.com\/kata\/52fba66badcd10859f00097e\/train\/javascript\">https:\/\/www.codewars.com\/kata\/52fba66badcd10859f00097e\/train\/javascript<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Trolls are attacking your comment section!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A common way to deal with this situation is to remove all of the vowels from the trolls&#8217; comments, neutralizing the threat.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your task is to write a function that takes a string and return a new string with all vowels removed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the string &#8220;This website is for losers LOL!&#8221; would become &#8220;Ths wbst s fr lsrs LL!&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note: for this kata <code>y<\/code> isn&#8217;t considered a vowel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>disemvowel=s=&gt;&#91;...s].filter(c=&gt;!\"aeiouAEIOU\".includes(c)).join('')<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It could be made shorter by using regular expressions but regex is its own meta-language.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It could argued that it would be made more clear by doing only one operation per line and using traditional functions declaration and for loops, but I am siding with the modern vs the traditional here:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">e.g.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function disemvowel(s){\n  output = \"\";\n  for(i=0;i&lt;s.length;i++){\n    if(!\"aeiouAEIOU\".includes(s&#91;i])){\n      output += s&#91;i];    \n    }\n  }\n  return output;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Links to MDN articles discussing the techniques used here:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Destructuring_assignment\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Destructuring_assignment<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/String\/includes\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/String\/includes<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/join\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/join<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: https:\/\/www.codewars.com\/kata\/52fba66badcd10859f00097e\/train\/javascript Trolls are attacking your comment section! A common way to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-post"],"_links":{"self":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=132"}],"version-history":[{"count":2,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}