JS – Async question 1 ..

Make it run without errors but you cannot change the location of the `let` statement, that has to stay at the end.

This was a trick question.

Callbacks are not async by default, this was a sync call so the message var was not defined by the time the callback was called.To make this work we need to wrap our call to `cb` in either a `setImmediate` or a `process.nextTick`.


Published by

Mhayk Whandson

Passionate about JavaScript, ReactJS, React Native, Node.js and the entire ecosystem around these technologies. A fullstack developer that has seen the bare metal coding Linux kernel drivers in C and multi-plataform desktop apps in C++/Qt5. Check my GitHub freebies at https://github.com/mhayk.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *