1
0
This commit is contained in:
Jason Williams 2019-08-25 14:34:31 -06:00
parent 126b14297a
commit 051270a264

33
playground/4-callbacks.js Normal file
View File

@ -0,0 +1,33 @@
// setTimeout(() => {
// console.log('Two seconds are up')
// }, 2000)
//
// const names = ['Jason', 'Jen', 'Jess']
// const shortNames = names.filter((name) => {
// return name.length <= 4
// })
//
// const geocode = (address, callback) => {
// setTimeout(() => {
// const data = {
// latitude: 0,
// longitude: 0
// }
//
// callback(data)
// }, 2000)
// }
//
// geocode('Philadelphia', (data) => {
// console.log(data)
// })
const add = (x, y, callback) => {
setTimeout(() => {
callback(x + y)
}, 2000)
}
add(1, 4, (sum) => {
console.log(sum) // Should print: 5
})