{"id":913,"date":"2017-04-19T13:19:17","date_gmt":"2017-04-19T21:19:17","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=913"},"modified":"2023-02-02T12:25:58","modified_gmt":"2023-02-02T20:25:58","slug":"trulia-phone-interview","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=913","title":{"rendered":"Trulia Phone Interview"},"content":{"rendered":"<p>PHP<\/p>\n<p>1) Difference between interface and abstract class. Write code to show example of each. Can a class derive from abstract class and implement an interface as well? (Yes)<\/p>\n<p>2) Write a function to test a palindrome.<\/p>\n<p>Javascript :<br \/>\n1) What is the difference between<br \/>\nx = 1;<br \/>\nvar x = 1;<br \/>\nwindow.x = 1;<\/p>\n<p>2) Write a function to add an array of numbers using the arguments variable<\/p>\n<pre>var data = [1,2,3,4];\r\nconsole.log(sum(data));\r\n\r\nfunction sum() {\r\n   var myData = arguments[0];\r\n   return myData.reduce(function (acc, num) { acc += num; return acc});\r\n}\r\n<\/pre>\n<p>3) write a function to implement mult(4)(5)<\/p>\n<pre>function mult(x) {\r\n   return function(y) {\r\n       return x*y;\r\n   }\r\n}\r\n\r\nvar ans = mult(4)(5);\r\n<\/pre>\n<p>Still concise :<\/p>\n<pre>function mult(num1) {\r\n  return num2 =&gt; num1 * num2;\r\n}\r\n\r\nconsole.log(mult(4)(5));<\/pre>\n<p>4) Write a function to output alert(1), alert(2) every 1 second till 5 times<br \/>\nSimilar to question asked in Ten-X interview.<\/p>\n<p>5) write a function to put spaces in a string &#8220;Hello World&#8221; ==&gt; &#8220;H e l l o W o r l d&#8221;.<\/p>\n<pre>var spacify = function (str) {\r\n    return str.split('').join(' ');\r\n};\r\n\r\nconsole.log(spacify(\"Hello\"));\r\n<\/pre>\n<p>Is it possible to write a function spacify like &#8220;hello world&#8221;.spacify()<\/p>\n<pre>String.prototype.spacify = String.prototype.spacify || function() {\r\n  return this.split('').join(' ');\r\n};\r\n\r\nconsole.log(\"Hello\".spacify());\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP 1) Difference between interface and abstract class. Write code to show example of each. Can a class derive from abstract class and implement an interface as well? (Yes) 2) Write a function to test a palindrome. Javascript : 1) What is the difference between x = 1; var x = 1; window.x = 1; &hellip; <a href=\"http:\/\/www.tech.dimprash.com\/?p=913\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Trulia Phone Interview<\/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":[15],"tags":[],"class_list":["post-913","post","type-post","status-publish","format-standard","hentry","category-interview-questions"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/913","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=913"}],"version-history":[{"count":8,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/913\/revisions"}],"predecessor-version":[{"id":1072,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/913\/revisions\/1072"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=913"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}