GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com setTimeout(() => {
console.log('Two seconds are up!');
}, 2000);
const names = ['Lakshman', 'Gope', 'Proddut'];
const shortNames = names.filter((name) => {
return name.length <= 4;
});
const geocode = (address, callback) => {
setTimeout(() => {
const data = {
latitude: 0,
longitude: 0
}
callback(data);
}, 2000);
};
geocode('Dhaka', (data) => {
console.log(data);
});
// Challenge
// Goal: Mess around with the callback pattern
//
// 1. Define an add function that accepts the correct arguments
// 2. Use setTimeout to simulate a 2 second delay
// 3. After 2 seconds are up, call the callback function with the sum
// 4. Test your work!
const add = (a, b, callback) => {
setTimeout(() => {
callback(a + b);
}, 2000);
}
add(1, 4, (sum) => {
console.log(sum) // Should print: 5
}) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |