1
   

Interview Question I can't figure out - Javascript

 
 
andy246
 
Reply Sat 27 Jun, 2015 08:32 am
Hi, I recently got an interview and I need to solve this problem. I can't figure it out though.... can anybody help?

QUESTION: Suppose findData is a function that takes a query object and returns a promise for the result of the query. Suppose also that somerandomArrayOfQueries is an array of query objects. Explain what would be printed by the following code and why:

function runMultipleQueries(queries) {
var results = [];
queries.forEach(doQuery);
return results;
function doQuery(query) {
findData(query)
.then(results.push.bind(results));
}
}

function log(value) {
console.log(value);
}

runMultipleQueries(somerandomArrayOfQueries).forEach(log);
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 1 • Views: 794 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » Interview Question I can't figure out - Javascript
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.34 seconds on 04/18/2024 at 11:55:36