Created
February 21, 2016 14:35
-
-
Save anonymous/1422765a813a90fca583 to your computer and use it in GitHub Desktop.
Найти ошибку в коде
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var database = { | |
myString: "hello world", | |
myNumber: 12 | |
} | |
function getFieldFromDB(callback, field) { | |
setTimeout(function() { | |
if (database == field) { | |
callback(null, database[field]); | |
} else { | |
callback('поле не найдено', database[field]); | |
} | |
}, 1000); | |
} | |
function prepareData(error, data) { | |
if (error) { | |
console.log('Ошибка: ' + error); | |
return; | |
} | |
console.log("Запрошенные данные: " + data); | |
} | |
function main() { | |
getFieldFromDB(prepareData, 'myString'); | |
getFieldFromDB(prepareData, 'myCat'); | |
getFieldFromDB(prepareData, 'myNumber'); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment