Skip to content

Instantly share code, notes, and snippets.

@lei-clearsky
Last active December 21, 2018 14:59
Show Gist options
  • Select an option

  • Save lei-clearsky/b43d4148f441abf3c34884f9f9e3a835 to your computer and use it in GitHub Desktop.

Select an option

Save lei-clearsky/b43d4148f441abf3c34884f9f9e3a835 to your computer and use it in GitHub Desktop.
// Problem 1
(() => {
console.log('this is the start');
setTimeout(function cb() {
console.log('this is a msg from call back');
});
console.log('this is just a message');
setTimeout(function cb1() {
console.log('this is a msg from call back1');
}, 0);
console.log('this is the end');
})();
// Problem 2
const bar = () => console.log('bar');
const baz = () => console.log('baz');
const foo = () => {
console.log('foo')
setTimeout(bar, 0);
new Promise((resolve, reject) =>
resolve('Promise Resolved!')
).then(resolve => console.log(resolve));
baz();
};
foo();
// Problem 3
// Make the following code work:
const a = [1, 2, 3, 4, 5];
// Implement this
a.multiply();
console.log(a); // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment