Shreyas arya

Generation

generate functionWed, 08 Feb 2023

Print string "Shreyas" and wait for 10 seconds. The total duration of all attempts doesn't exceed 10 seconds. Maximum attemps is 3

Script function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } function print(name, maxAttempts, maxDuration) { var counter = 0 var start = new Date().getTime(); var end = start; var totalDuration = 0; for (var i = 0; i < maxAttempts; i++) { console.log(name) sleep(10000) end = new Date().getTime(); totalDuration = end - start; if (totalDuration >= maxDuration) { break; } } } print("Shreyas", 3, 10000)

Questions about programming?Chat with your personal AI assistant