ClearFeed Interview Question

Write a stress testing program to keep pinging an endpoint in javascript.

Interview Answer

Anonymous

Aug 21, 2023

I had the right idea, though I guess the solution wasn't exactly to their liking since I didn't leverage the response of the resolve parameter, I was working it out on a whiteboard. /// Probably what was expected const requests = []; let count = 0; const MAX_SENDS = 1000; const COMPLETE_INDEX = -1 const sendPing = async (index, time = Math.random() * 100) => { return new Promise((resolve) => { if (count { const index = await Promise.any(requests); requests[index] = sendPing(index); if (index === COMPLETE_INDEX) { console.log("DONE"); } else { stressTest(count++); } }; stressTest();