Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sleep sort

/* For each number in an array, an asynchronous timer lasting the
length of the number is set, printing the number once the timer is up.*/
const numbers = [1, 6, 3, 5, 4, 2]

numbers.forEach(num => {
    setTimeout(() => console.log(num), num)
});
 
PREVIOUS NEXT
Tagged: #sleep #sort
ADD COMMENT
Topic
Name
5+4 =