{"id":15,"date":"2017-04-20T14:48:46","date_gmt":"2017-04-20T14:48:46","guid":{"rendered":"https:\/\/code.jamesash.com\/?p=15"},"modified":"2017-04-20T14:48:46","modified_gmt":"2017-04-20T14:48:46","slug":"unique-characters-in-a-string-challenge","status":"publish","type":"post","link":"https:\/\/code.jamesash.com\/?p=15","title":{"rendered":"Unique Characters In A String Challenge"},"content":{"rendered":"<p>I found <a href=\"https:\/\/discuss.codecademy.com\/t\/challenge-unique-characters-in-a-string\/82151\">a challenge on Codecademy<\/a>\u00a0about building a function that checks a string to see if all of the characters are unique. It seemed like a pretty straightforward challenge. Here is what I came up with using javascript:<\/p>\n<pre><code>function dupeCheck() {\r\n\u00a0\u00a0var x = 'qsxthfeavyjkowmp'\r\n\u00a0\u00a0var dupe = 0;\r\n\u00a0\u00a0for (i = 0; i &lt; x.length; i++) {\r\n\u00a0\u00a0\u00a0var letter = x.charAt(i);\r\n\u00a0\u00a0\u00a0var checker = x.indexOf(letter, i+1);\r\n\u00a0\u00a0\u00a0if (checker &gt; 0) {dupe = dupe + 1;}\r\n\u00a0\u00a0}\r\n\u00a0\u00a0if (dupe &gt; 0) {\r\n\u00a0\u00a0\u00a0alert(\"Duplicate Characters Were Found In Your String\")\r\n\u00a0\u00a0} else {\r\n\u00a0\u00a0\u00a0alert(\"Your string does not contain duplicate characters.\")\r\n\u00a0\u00a0}\r\n\u00a0}<\/code><\/pre>\n<p>Originally, I was passing the string as a variable, but to turn it in, I switched it to a variable in the function. I think it&#8217;s pretty self explanatory. I&#8217;m taking each character in the string and checking to see if it appears again in the string. If it does, I add to the counter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found a challenge on Codecademy\u00a0about building a function that checks a string to see if all of the characters are unique. It seemed like a pretty straightforward challenge. Here is what I came up with using javascript: function dupeCheck() { \u00a0\u00a0var x = &#8216;qsxthfeavyjkowmp&#8217; \u00a0\u00a0var dupe = 0; \u00a0\u00a0for (i = 0; i &lt; &hellip; <a href=\"https:\/\/code.jamesash.com\/?p=15\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Unique Characters In A String Challenge<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15"}],"version-history":[{"count":1,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=\/wp\/v2\/posts\/15\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/code.jamesash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.jamesash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}