Embercode
✕
Asynchronous JavaScriptCoding problems

Asynchronous JavaScript: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 8 solved

  • A kitchen has several timers. Each timer has a label and a delay in milliseconds, and all of them are started at the same moment. Print the labels in the order the timers ring. When two timers have the same delay, the one listed first rings first.

    Use setTimeout to schedule each label so the order comes from the event loop.

    Input. The first line has `n` (1 to 8). Each of the next `n` lines has a label (one word) and a delay (0 to 50), separated by a space.

    Output. The `n` labels, one per line, in the order they ring.

    Example 1 input

    3
    pasta 30
    rice 10
    tea 20
    

    Output

    rice
    tea
    pasta