{"id":745,"date":"2017-02-25T17:07:19","date_gmt":"2017-02-26T01:07:19","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=745"},"modified":"2017-02-25T17:08:00","modified_gmt":"2017-02-26T01:08:00","slug":"example-of-associative-array-in-javascript","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=745","title":{"rendered":"Example of Associative Array in Javascript"},"content":{"rendered":"<p>Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence &#8220;The quick brown fox jumps over the lazy dog&#8221; repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.)<\/p>\n<p>After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams.<\/p>\n<p>Given a sentence , tell Roy if it is a pangram or not.<\/p>\n<p>E.g: We promptly judged antique ivory buckles for the next prize  <\/p>\n<pre>\r\nfunction processData(input) {\r\n    \/\/Enter your code here\r\n    var inpArr = input.split(\"\");\r\n    var uinput = input.toUpperCase();\r\n    var freqObj = {};\r\n    for (var a=65; a <= 90 ; a++) {\r\n        var s = String.fromCharCode(a);\r\n        freqObj[s] = 0;  \/\/ associative array as an object\r\n    }\r\n    \r\n    for (var i = 0; i < uinput.length ; i++) {\r\n        \r\n        var char = uinput[i];\r\n        \/\/if (char in freqObj) {\r\n        if ((char in freqObj) &#038;&#038; (freqObj.hasOwnProperty(char)) ) {\r\n            freqObj[char] = 1;\r\n        } \r\n        \r\n    }\r\n    \r\n    var okeys = Object.keys(freqObj);\r\n    var sum = 0;\r\n    for (var k = 0; k < okeys.length; k++) {\r\n        if (freqObj.hasOwnProperty(okeys[k])) {\r\n            sum += freqObj[okeys[k]];\r\n        }\r\n    }\r\n    \r\n    if (sum == 26) {\r\n        console.log(\"pangram\");\r\n    } else {\r\n        console.log(\"not pangram\");\r\n    }\r\n    \r\n} \r\n\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"ascii\");\r\n_input = \"\";\r\nprocess.stdin.on(\"data\", function (input) {\r\n    _input += input;\r\n});\r\n\r\nprocess.stdin.on(\"end\", function () {\r\n   processData(_input);\r\n});\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence &#8220;The quick brown fox jumps over the lazy dog&#8221; repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.) After typing the sentence several times, Roy &hellip; <a href=\"http:\/\/www.tech.dimprash.com\/?p=745\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Example of Associative Array in Javascript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-745","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=745"}],"version-history":[{"count":2,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/745\/revisions"}],"predecessor-version":[{"id":747,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/745\/revisions\/747"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}