{"id":4727,"date":"2024-05-28T22:32:01","date_gmt":"2024-05-28T17:02:01","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=4727"},"modified":"2024-05-28T22:32:02","modified_gmt":"2024-05-28T17:02:02","slug":"print-12345-in-12345-seconds-respectively-without-using-let-frontend-javascript-interview-question","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/print-12345-in-12345-seconds-respectively-without-using-let-frontend-javascript-interview-question\/","title":{"rendered":"Print 1,2,3,4,5 in 1,2,3,4,5 seconds respectively without using let | Frontend JavaScript Interview Question"},"content":{"rendered":"<p>Hi all,<\/p>\n<p>I also figured out another way out to write the code for printing 1,2,3,4,5 in 1,2,3,4,5 seconds respectively without using let and only using var. this is regarding EP-11 | setTimeout + closures interview questions (\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=eBTBG4nda2A&amp;list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&amp;index=13\">https:\/\/www.youtube.com\/watch?v=eBTBG4nda2A&amp;list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&amp;index=13<\/a> ). i have given the code below, kindly let me know if this could be considered as an another solution since it was giving me the correct output.<\/p>\n<pre class=\"ql-syntax\">function altSol(){\nfor (var i = 1;i&lt;=5; i++){\n     setTimeout(function (i){\n      console.log(i);\n        }(i),i*1000);  \n      }\n   }\naltSol();\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hi all, I also figured out another way out to write the code for printing 1,2,3,4,5 in 1,2,3,4,5 seconds respectively without using let and only using var. this is regarding EP-11 | setTimeout + closures interview questions (\u00a0https:\/\/www.youtube.com\/watch?v=eBTBG4nda2A&amp;list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&amp;index=13 ). i have given the code below, kindly let me know if this could be considered as<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[231,222,314],"tags":[221,337,330],"class_list":["post-4727","post","type-post","status-publish","format-standard","category-article","category-interview","category-interview-preparation","tag-interview","tag-interview-preparation","tag-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=4727"}],"version-history":[{"count":2,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4727\/revisions"}],"predecessor-version":[{"id":4731,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/4727\/revisions\/4731"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=4727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=4727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=4727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}