const dbQuery = (query) => {
return new Promise( (resolve, reject) => {
setTimeout( ()=> { resolve(`Results for db query: ${query}`) }, 1000 * Math.floor(5*Math.random()) );
} )
}
const queries = ['Query 1', 'Query 2', 'Query 3', 'Query 4', 'Query 5'];
// Fix this snippet of code so that it prints the query results
queries.forEach( q => console.log(dbQuery(q)) );
const dbQuery = (query) => {
return new Promise( (resolve, reject) => {
setTimeout( ()=> { resolve(`Results for db query: ${query}`) }, 1000 * Math.floor(5*Math.random()) );
} )
}
const queries = ['Query 1', 'Query 2', 'Query 3', 'Query 4', 'Query 5'];
// Fix this snippet of code so that it prints the query results
queries.forEach( q => console.log(dbQuery(q)) );
This file contains 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
const dbQuery = (query) => { | |
return new Promise( (resolve, reject) => { | |
setTimeout( ()=> { resolve(`Results for db query: ${query}`) }, 1000 * Math.floor(5*Math.random()) ); | |
} ) | |
} | |
const queries = ['Query 1', 'Query 2', 'Query 3', 'Query 4', 'Query 5']; | |
// Fix this snippet of code so that it prints the query results | |
queries.forEach( q => console.log(dbQuery(q)) ); |