Question 1
Consider the following JavaScript code.
function promiseBuilder(t) { return new Promise((res, rej) => { setTimeout(() => { const count = Math.floor(t / 1000) if (count > 3) { res(count) } else { rej(count * 2) } }, t) })}
async function getData() { let data1 = null, data2 = null try { data1 = await promiseBuilder(5000) } catch (e) { data1 = 30 } try { data2 = await promiseBuilder(2000) } catch (e) { data2 = 40 } return data1 + data2}
getData().then( (res) => { console.log(8 * res) }, (err) => { console.log(6 * err) })What will be logged on to the console?
56
272
360
560
