Question 1
Consider the below javascript program.
function data(d) { return new Promise((res) => { setTimeout(() => res('Your Data'), d * 1000) })}
function delta(d) { return new Promise((res) => { if (d > 3) { setTimeout(() => res('delta'), d * 500) } else { return res('delta') } })}async function getData(d) { const start = Date.now() const _delta = await delta(d) const _data = await data(d) const end = Date.now() const timeDifference = end - start}
getData(4)What will be the approximate value of the variable “timeDifference”?
Less than 4000
Is equal to 4000
Greater than or equal to 6000
None of these