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 ( https://www.youtube.com/watch?v=eBTBG4nda2A&list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&index=13 ). 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.
function altSol(){ for (var i = 1;i<=5; i++){ setTimeout(function (i){ console.log(i); }(i),i*1000); } } altSol();
8 Comments
thiscode throws an error
node:internal/validators:440
throw new ERR_INVALID_ARG_TYPE(name, ‘Function’, value);
1
I like the comprehensive information you provide in your blog. The topic is kinda complex but I’d have to say you nailed it! Look into my page QN7 for content about Car Purchase.
1
I like this site because so much useful material on here : D.
Its fantastic as your other blog posts : D, appreciate it for putting up.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Hello! This post couldn’t be written any better! Reading this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Fairly certain he will have a good read. Thank you for sharing!